/********************************************************************/ /* ANTIDUMPING MARKET ECONOMY */ /* MACROS PROGRAM */ /* */ /* GENERIC VERSION LAST UPDATED AUGUST 16, 2022 */ /* */ /********************************************************************/ /* GENERAL MACROS */ /*------------------------------------------------------------------*/ /* G1_RUNTIME_SETUP */ /* G2_TITLE_SETUP */ /* G3_COST_TIME_MVARS */ /* G4_LOT */ /* G5_DATE_CONVERT */ /* G6_CHECK_SALES */ /* G7_EXRATES */ /* G8_FIND_NOPRODUCTION */ /* G9_COST_PRODCHARS */ /* G10_TIME_PROD_LIST IN QUARTERLY COST SITUATIONS */ /* G11_CREATE_TIME_COST_DB IN QUARTERLY COST SITUATIONS */ /* G12_ZERO_PROD_IN_PERIODS IN QUARTERLY COST SITUATIONS */ /* G13_CREATE_COST_PROD_TIMES IN QUARTERLY COST SITUATIONS */ /* G14_HIGH_INFLATION */ /* G15_CHOOSE_COSTS */ /* G16_MATCH_NOPRODUCTION IN NON-HIGH INFLATION SITUATIONS OR */ /* NON-QUARTERLY COST SITUATIONS */ /* G17_FINALIZE_COSTDATA */ /* G18_DEL_ALL_WORK_FILES */ /* G19_PROGRAM_RUNTIME */ /*------------------------------------------------------------------*/ /* COMPARISON MARKET MACROS */ /*------------------------------------------------------------------*/ /* HM1_PRIME_MANUF_MACROS */ /* HM2_MIXEDCURR */ /* HM3_ARMSLENGTH */ /* HM4_CEPTOT */ /* HM5_COSTTEST */ /* HM6_DATA_4_WTAVG */ /* HM7_WTAVG_DATA */ /* HM8_CVSELL */ /* HM9_LOTADJ */ /*------------------------------------------------------------------*/ /* MARGIN PROGRAM MACROS */ /*------------------------------------------------------------------*/ /* US1_MACROS */ /* US2_SALETYPE */ /* US3_USD_CONVERSION */ /* US4_INDCOMM */ /* US5_CEPRATE */ /* US6_ENTVALUE */ /* US7_CONCORDANCE */ /* US8_LOTADJ */ /* US9_OFFSETS */ /* US10_LOT_ADJUST_OFFSETS */ /* US11_CVSELL_OFFSETS */ /* US12_COMBINE_P2P_CV */ /* US13_COHENS_D_TEST */ /* US14_WT_AVG_DATA */ /* US15_RESULTS */ /* US16_CALC_CASH_DEPOSIT */ /* US17_MEANINGFUL_DIFF_TEST */ /* US18_ASSESSMENT */ /* US19_FINAL_CASH_DEPOSIT */ /********************************************************************/ /********************************************************/ /* G-1: SET UP MACRO VARIABLES FOR RUN TIME CALCULATION */ /********************************************************/ %MACRO G1_RUNTIME_SETUP; DATA _NULL_; CALL SYMPUT('BDAY', STRIP(PUT(DATE(), DOWNAME.))); CALL SYMPUT('BWDATE', STRIP(PUT(DATE(), WORDDATE18.))); CALL SYMPUT('BTIME', STRIP(PUT(TIME(), TIMEAMPM8.))); CALL SYMPUT ('BDATE',PUT(DATE(),DATE.)); CALL SYMPUT('BDATETIME', (STRIP(PUT(DATETIME(), 20.)))); RUN; %PUT NOTE: This program started running on &BDAY, &BWDATE at &BTIME..; %MEND G1_RUNTIME_SETUP; %GLOBAL INDEX_SOURCE TIME_OUTSIDE_POR TIME_ANNUALIZED; %LET INDEX_SOURCE = NA; %LET TIME_OUTSIDE_POR = NA; %LET TIME_ANNUALIZED = NA; /***********************************************************/ /* G-2: CREATE FIXED TITLES AND FOOTNOTES ON LINES 1 AND 2 */ /* FOR EACH PRINT AND PROGRAM-SPECIFIC MACROS FOR TITLES 3 */ /* AND HIGHER */ /***********************************************************/ %MACRO G2_TITLE_SETUP; %GLOBAL PROGRAM SALES_DB CALC_TYPE; %IF %UPCASE(&SALESDB) = HMSALES %THEN %DO; %LET PROGRAM = HOME MARKET; %LET SALES_DB = HOME MARKET; %END; %ELSE %IF %UPCASE(&SALESDB) = USSALES %THEN %DO; %LET PROGRAM = U.S. SALES MARGIN; %LET SALES_DB = U.S.; %END; %IF %UPCASE(&CASE_TYPE) = AR %THEN %DO; %LET CALC_TYPE = RESULTS; %END; %ELSE %IF %UPCASE(&CASE_TYPE) = INV %THEN %DO; %LET CALC_TYPE = DETERMINATION; %END; %ELSE %DO; %LET CALC_TYPE = ; %END; TITLE1 "&PROGRAM PROGRAM - &PRODUCT FROM &COUNTRY (&BEGINPERIOD - &ENDPERIOD)"; TITLE2 "&SEGMENT &STAGE FOR RESPONDENT &RESPONDENT (&CASE_NUMBER)"; FOOTNOTE1 "*** BUSINESS PROPRIETARY INFORMATION SUBJECT TO APO ***"; FOOTNOTE2 "&BDAY, &BWDATE - &BTIME"; %MEND G2_TITLE_SETUP; /*****************************************/ /* G3: CREATE MACROS FOR QUARTERLY COSTS */ /*****************************************/ %MACRO G3_COST_TIME_MVARS; %GLOBAL HM_TIME_PERIOD NAF_TIME_PERIOD COST_TIME_PERIOD US_TIME_PERIOD US_TIME AND_TIME EQUAL_TIME OR_TIME FIRST_TIME COP_TIME_OUT COST_PERIODS TIME_ANNUAL ANNUAL_COST; /*--------------------------------------------*/ /* Define format for different kinds of Cost. */ /*--------------------------------------------*/ PROC FORMAT; VALUE $TIMETYPE 'AN' = 'Reported Annualized' 'SG' = 'Surrogate Annualized' 'Q1' = 'Reported Quarterly' 'Q2' = 'Blended Surrogate Quarterly' 'Q3' = 'Gap Fill Surrogate Quarterly' 'H1' = 'Reported High Inflation' 'H2' = 'Annualized High Inflation' 'H3' = 'Surrogate High Inflation' 'CA' = 'Calculated' 'NA' = 'N/A'; RUN; %IF %UPCASE(&COMPARE_BY_TIME) = YES %THEN %DO; %LET AND_TIME = AND; %LET EQUAL_TIME = =; %LET OR_TIME = OR; %LET FIRST_TIME = FIRST.&US_TIME_PERIOD; %LET US_TIME = US_TIME_PERIOD; /* For Level of Trade calculation */ /* in CM program. */ %LET COST_PERIODS = COST PERIODS; %LET HM_TIME_PERIOD = HM_TIME_PERIOD; %IF %UPCASE(&TIME_ANNUALIZED) = NA %THEN %DO; %LET TIME_ANNUAL = ; %LET ANNUAL_COST = ; %END; %IF %UPCASE(&TIME_ANNUALIZED) NE NA %THEN %DO; %LET TIME_ANNUAL = ,&TIME_ANNUALIZED; %LET ANNUAL_COST = ANNUALCOST; %END; %IF %UPCASE(&SALESDB) = HMSALES %THEN %DO; %LET NAF_TIME_PERIOD = NAF_TIME_PERIOD; %LET COP_TIME_OUT = COST_TIME_PERIOD; %END; %IF %UPCASE(&SALESDB) = USSALES %THEN %DO; %LET HM_TIME_PERIOD = HM_TIME_PERIOD; %END; %END; %IF %UPCASE(&COMPARE_BY_TIME) = NO %THEN %DO; %LET HM_TIME_PERIOD = ; %LET COST_TIME_PERIOD = ; %LET NAF_TIME_PERIOD = ; %LET US_TIME_PERIOD = ; %LET US_TIME = ; %LET AND_TIME = ; %LET EQUAL_TIME = ; %LET COP_TIME_OUT = ; %LET COST_PERIODS = ; %LET TIME_ANNUAL = ; %LET ANNUAL_COST = ; %END; %MEND G3_COST_TIME_MVARS; /*******************************************************************/ /* G4: CREATE LEVEL OF TRADE VARIABLE FOR PROGRAMMING USE BASED ON */ /* INFORMATION IN MACRO VARIABLE 'LET HMLOT = ' */ /*******************************************************************/ %MACRO G4_LOT(LOT_REP, LOT_PROG); %IF %UPCASE(&LOT_REP) NE NA %THEN %DO; &LOT_PROG = &LOT_REP; %END; %ELSE %IF %UPCASE(&LOT_REP) EQ NA %THEN %DO; &LOT_PROG = 0; %END; %MEND G4_LOT; /*******************************************************************/ /* G-5: TEST SALE DATE VARIABLE FORMAT */ /* */ /* If your date variable is not in SAS date format, the language */ /* below will attempt to convert it. If the conversion is not */ /* successful, please contact a SAS support person for assistance. */ /*******************************************************************/ %MACRO DATE_CONVERT(DATE, TYPE); %GLOBAL SALEDATE_FORMAT DATE_FORMAT&TYPE; DATA _NULL_; SET &SALESDB; IF _N_=1 THEN DO; LENGTH SALEDATEFORM $4; SALEDATEFORM = VFORMATN(&DATE); IF SUBSTR(SALEDATEFORM,1,1) = '$' THEN SALEDATE_FORMAT_TYPE = 'CHARACTER'; ELSE IF SALEDATEFORM IN( 'DATE','WEEK','YYMM', 'MMDD','WORD') THEN SALEDATE_FORMAT_TYPE = 'DATE'; ELSE SALEDATE_FORMAT_TYPE = 'NUMERIC'; CALL SYMPUT ('SALEDATE_FORMAT',SALEDATE_FORMAT_TYPE); END; RUN; %IF &SALEDATE_FORMAT = DATE %THEN %DO; %LET DATE_FORMAT&TYPE = YES; %END; /*********************************************/ /* Attempt to convert the sale date variable */ /* to date format, when necessary. */ /*********************************************/ %IF &SALEDATE_FORMAT NE DATE %THEN %DO; DATA &SALESDB; SET &SALESDB (RENAME = (&DATE = DATE_TEMP)); FORMAT &DATE DATE9.; &DATE = INPUT(DATE_TEMP, ANYDTDTE21.); RUN; /************************************************/ /* Retest the format of converted date variable */ /* to see if conversion was successful. */ /************************************************/ DATA _NULL_; LENGTH CONVERTDATEFORM $4; SET &SALESDB; IF _N_ = 1; CONVERTDATEFORM = VFORMATN(&DATE); IF CONVERTDATEFORM IN('DATE','WEEK','YYMM', 'MMDD','WORD') THEN CONVERTDATE = 'YES'; ELSE CONVERTDATE = 'NO'; CALL SYMPUT('CONVERT_SUCCESS', CONVERTDATE); RUN; %IF &CONVERT_SUCCESS = YES %THEN %DO; %LET DATE_FORMAT&TYPE = YES; PROC PRINT DATA = &SALESDB (OBS = &PRINTOBS) SPLIT="*"; VAR DATE_TEMP &DATE; LABEL DATE_TEMP = "ORIGINAL*DATE*VARIABLE*===========" &DATE = "CONVERTED*DATE*VARIABLE*==========="; TITLE3 "CHECK OF SALE DATE VARIABLE CONVERSION, FIRST &PRINTOBS OBSERVATIONS"; TITLE5 "If converted data is missing or not correct, further action will be required."; TITLE6 "If original data is missing and the converted date is 01JAN1960, then variable &date is uninitialized."; RUN; %END; %ELSE %IF &CONVERT_SUCCESS = NO %THEN %DO; %LET DATE_FORMAT&TYPE = NO; PROC PRINT DATA = &SALEDB (OBS = &PRINTOBS) SPLIT="*"; VAR DATE_TEMP &DATE; LABEL DATE_TEMP = "ORIGINAL*DATE*VARIABLE*===========" &DATE = "CONVERTED*DATE*VARIABLE*==========="; TITLE3 "THE AUTOMATIC ATTEMPT TO CONVERT &DATE, A &SALEDATE_FORMAT VARIABLE, WAS NOT SUCCESSFUL."; TITLE5 "Note: Before exchange rates can be merged or month designations assigned in administrative,"; TITLE6 "reviews, the variable will have to be converted to SAS date format by an alternative method."; RUN; %END; %END; %MEND DATE_CONVERT; %MACRO G5_DATE_CONVERT; %IF %UPCASE(&SALESDB) = HMSALES %THEN %DO; %DATE_CONVERT(&HMSALEDATE, ) %END; %ELSE %IF %UPCASE(&SALESDB) = DOWNSTREAM %THEN %DO; %DATE_CONVERT(&HMSALEDATE, ) %END; %ELSE %IF %UPCASE(&SALESDB) = USSALES %THEN %DO; %DATE_CONVERT(&USSALEDATE, ) %IF %UPCASE(&FILTER_EP) = YES %THEN %DO; %DATE_CONVERT(&EP_DATE_VAR,_EP) %END; %IF %UPCASE(&FILTER_CEP) = YES %THEN %DO; %DATE_CONVERT(&CEP_DATE_VAR,_CEP) %END; %END; %MEND G5_DATE_CONVERT; /*****************************************************************************/ /* G-6: CHECK SALES FOR NEGATIVE PRICES AND QUANTITIES, DATES OUTSIDE PERIOD */ /*****************************************************************************/ %MACRO G6_CHECK_SALES; %GLOBAL MONTH; %LET MONTH = ; /* Null value for macro variables &HMMONTH or &USMONTH for investigations. */ %MACRO CHECK_SALES(SALES_MONTH, QTY,GUP, DATE, SALES, DBTYPE, DB, BEGINDAY, ENDDAY); DATA &SALES NEGDATA_&DB OUTDATES_&DB; SET &SALES; IF &QTY LE 0 OR &GUP LE 0 THEN OUTPUT NEGDATA_&DB; ELSE IF "&BEGINDAY."D GT &DATE OR &DATE GT "&ENDDAY."D THEN OUTPUT OUTDATES_&DB; %MARGIN_FILTER ELSE DO; /*--------------------------------------------------------------------*/ /* In administrative reviews, define HMMONTH and USMONTH variables so */ /* that each month has a unique value. */ /*--------------------------------------------------------------------*/ %IF %UPCASE(&CASE_TYPE) = AR %THEN %DO; %IF &DBTYPE = US %THEN %DO; %LET BEGIN = &HMBEGINWINDOW; %END; %ELSE %DO; %LET BEGIN = &HMBEGINDAY; %END; MON = MONTH(&DATE); YRDIFF = YEAR(&DATE) - YEAR("&BEGIN."D); &SALES_MONTH = MON + YRDIFF * 12; DROP MON YRDIFF; %LET MONTH = &SALES_MONTH; %END; OUTPUT &SALES; END; RUN; PROC PRINT DATA = NEGDATA_&DB (OBS = &PRINTOBS); TITLE3 "SAMPLE OF &DBTYPE SALES WITH GROSS PRICE (&GUP) OR QUANTITY (&QTY) LESS THAN OR EQUAL TO ZERO"; TITLE5 "NOTE: Default programming removes these sales from the calculations."; TITLE6 "Should this not be appropriate, adjust accordingly."; RUN; PROC PRINT DATA = OUTDATES_&DB (OBS = &PRINTOBS); TITLE3 "SAMPLE OF &DBTYPE SALES OUTSIDE THE PERIOD OF ANALYSIS"; TITLE4 "BASED ON THE VALUE OF &DATE BEING OUTSIDE THE DATE RANGE &BEGINDAY AND &ENDDAY"; TITLE6 "NOTE: Default programming removes these sales from the calculations."; TITLE7 "Should this not be appropriate, adjust accordingly."; RUN; %MEND CHECK_SALES; %IF %UPCASE(&SALESDB) = HMSALES %THEN %DO; %MACRO MARGIN_FILTER; %MEND MARGIN_FILTER; %CHECK_SALES(HMMONTH, &HMQTY, &HMGUP, &HMSALEDATE, HMSALES, HOME MARKET, HM, &HMBEGINDAY, &HMENDDAY); %END; %IF %UPCASE(&SALESDB) = DOWNSTREAM %THEN %DO; %MACRO MARGIN_FILTER; %MEND MARGIN_FILTER; %CHECK_SALES(HMMONTH, &HMQTY, &HMGUP, &HMSALEDATE, DOWNSTREAM, DOWNSTREAM, DS, &HMBEGINDAY, &HMENDDAY); %END; %IF %UPCASE(&SALESDB) = USSALES %THEN %DO; %MACRO MARGIN_FILTER; %IF %UPCASE(&FILTER_CEP) = YES %THEN %DO; %IF &DATE_FORMAT_CEP = YES %THEN %DO; ELSE IF SALE_TYPE = "CEP" AND ("&BEGINDAY_CEP."D GT &CEP_DATE_VAR OR &CEP_DATE_VAR GT "&ENDDAY_CEP."D) THEN OUTPUT OUTDATES_&DB; %END; %END; %IF %UPCASE(&FILTER_EP) = YES %THEN %DO; %IF &DATE_FORMAT_EP = YES %THEN %DO; ELSE IF SALE_TYPE = "EP" AND ("&BEGINDAY_EP."D GT &EP_DATE_VAR OR &EP_DATE_VAR GT "&ENDDAY_EP."D) THEN OUTPUT OUTDATES_&DB; %END; %END; %MEND MARGIN_FILTER; %CHECK_SALES(USMONTH, &USQTY, &USGUP, &USSALEDATE, USSALES, US, US, &USBEGINDAY, &USENDDAY); %END; %MEND G6_CHECK_SALES; /*************************************************/ /* G-7: MERGE EXCHANGE RATES INTO SALES DATABASE */ /*************************************************/ %MACRO G7_EXRATES; %GLOBAL EXRATE1 XRATE1 EXRATE2 XRATE2; %MACRO MERGE_RATES(USE_EXRATES, EXDATA, EXRATE, XRATE,DATE); /*----------------------------------------------*/ /* Set values for exchange rate macro variables */ /* when exchange rate is not required. */ /*----------------------------------------------*/ %IF %UPCASE(&USE_EXRATES) = NO %THEN %DO; %LET &EXRATE = ; %LET &XRATE = 1; %END; /*--------------------------------------*/ /* Merge Exchange Rates, when required. */ /*--------------------------------------*/ %IF %UPCASE(&USE_EXRATES) = YES %THEN %DO; %LET &EXRATE = EXRATE_&EXDATA; %LET &XRATE = EXRATE_&EXDATA; /*----------------------------------------------------*/ /* First establish whether date variable is in proper */ /* format before attempting to merge exchange rates. */ /*----------------------------------------------------*/ %IF &DATE_FORMAT = YES %THEN %DO; /*---------------------------------------------------*/ /* If date variable is in proper format, merge in */ /* format before attempting to merge exchange rates. */ /*---------------------------------------------------*/ PROC SORT DATA = COMPANY.&EXDATA (RENAME = (DATE = &DATE %IF %UPCASE(&CASE_TYPE) = INV %THEN %DO; &EXDATA.I = EXRATE_&EXDATA) DROP = &EXDATA.R) %END; %ELSE %IF %UPCASE(&CASE_TYPE) = AR %THEN %DO; &EXDATA.R = EXRATE_&EXDATA) DROP = &EXDATA.I) %END; OUT = EXRATES; BY &DATE; RUN; PROC SORT DATA = &SALESDB OUT = &SALESDB; BY &DATE; RUN; DATA &SALESDB NORATES; MERGE &SALESDB (IN = A) EXRATES (IN = B); BY &DATE; IF A & B THEN OUTPUT &SALESDB; ELSE IF A & NOT B THEN OUTPUT NORATES; RUN; PROC PRINT DATA = NORATES; VAR &DATE; TITLE3 "&SALESDB WITH NO EXCHANGE RATES FOR &EXDATA"; RUN; %END; %END; %MEND MERGE_RATES; %IF %UPCASE(&SALESDB) = HMSALES %THEN %DO; %MERGE_RATES(&USE_EXRATES1, &EXDATA1, EXRATE1, XRATE1, &HMSALEDATE); %MERGE_RATES(&USE_EXRATES2, &EXDATA2, EXRATE2, XRATE2, &HMSALEDATE); %END; %ELSE %IF %UPCASE(&SALESDB) = USSALES %THEN %DO; %MERGE_RATES(&USE_EXRATES1, &EXDATA1, EXRATE1, XRATE1, &USSALEDATE); %MERGE_RATES(&USE_EXRATES2, &EXDATA2, EXRATE2, XRATE2, &USSALEDATE); %END; %ELSE %IF %UPCASE(&SALESDB) = DOWNSTREAM %THEN %DO; %MERGE_RATES(&USE_EXRATES1, &EXDATA1, EXRATE1, XRATE1, &HMSALEDATE); %MERGE_RATES(&USE_EXRATES2, &EXDATA2, EXRATE2, XRATE2, &HMSALEDATE); %END; %MEND G7_EXRATES; /**********************************************************/ /* G-8 IDENTIFY PRODUCTS REQUIRING SURROGATE COSTS */ /* */ /* CONNUMUs in the CM and U.S. datasets that have sales */ /* but no production in the POI/POR must be in the COP */ /* dataset with a production quantity of 0 (zero). If */ /* respondent does not report these CONNUMs in the cost */ /* dataset, the analyst must add these CONNUMs to the COP */ /* dataset with a production quantity of 0 (zero). */ /**********************************************************/ %MACRO G8_FIND_NOPRODUCTION; /********************************************************************************/ /* G-8-A: Annualized Cost, High Inflation, OR Quarterly Cost without production */ /********************************************************************************/ %IF %UPCASE(&COMPARE_BY_HIGH_INFLATION) EQ NO %THEN %DO; /*************************************************************************/ /* G-8-A-i: Define macro variables and macros used in finding annualized */ /* Cost or quarterly Cost without production. */ /*************************************************************************/ %GLOBAL EQUAL_COST_PRIME NO_PROD_COST_PRIME TIME_ANNUALIZED; %LET TIME_ANNUALIZED = NA; /*-----------------------------------------------------------------------------------*/ /* Create null values for macro variables when Cost prime/non-prime is not relevant. */ /*-----------------------------------------------------------------------------------*/ %IF %UPCASE(&COST_PRIME) EQ NA %THEN %DO; %LET EQUAL_COST_PRIME = ; /* EQUAL operator for cost prime purposes */ %LET NO_PROD_COST_PRIME = ; /* no production cost prime */ %END; %ELSE /*---------------------------------------------------------------*/ /* Create macro variables when Cost prime/non-prime is relevant. */ /*---------------------------------------------------------------*/ %IF %UPCASE(&COST_PRIME) NE NA %THEN %DO; %LET EQUAL_COST_PRIME = =; %LET NO_PROD_COST_PRIME = NO_PROD_&COST_PRIM; %END; PROC SORT DATA = COST OUT = COST; BY &COST_MANF &COST_PRIM &COST_MATCH &COST_TIME_PERIOD; RUN; %IF %UPCASE(&COST_PROD_CHARS) = YES %THEN %DO; %LET PROD_CHARS = &COST_CHAR; %END; %ELSE %IF %UPCASE(&COST_PROD_CHARS) = NO %THEN %DO; %LET PROD_CHARS = ; %END; %IF %UPCASE(&COMPARE_BY_TIME) = YES %THEN %DO; %MACRO WHERE_STMT; %MEND WHERE_STMT; %IF %UPCASE(&TIME_ANNUALIZED) EQ NA %THEN %DO; %MACRO NOPROD_TIME_TYPE; NOPROD_TIME_TYPE = 'Q1'; %MEND NOPROD_TIME_TYPE; %END; %ELSE %IF %UPCASE(&TIME_ANNUALIZED) NE NA %THEN %DO; %MACRO NOPROD_TIME_TYPE; NOPROD_TIME_TYPE = 'Q1'; IF &COST_TIME_PERIOD IN(&TIME_ANNUALIZED) THEN NOPROD_TIME_TYPE = "AN"; %MEND NOPROD_TIME_TYPE; %END; %MACRO RENAME_TIME_TYPE; &COST_TIME_PERIOD = NO_PRODUCTION_QUARTER %MEND RENAME_TIME_TYPE; %END; %ELSE %IF %UPCASE(&COMPARE_BY_TIME) = NO %THEN %DO; %MACRO WHERE_STMT; %MEND WHERE_STMT; %MACRO NOPROD_TIME_TYPE; NOPROD_TIME_TYPE = "NA"; %MEND NOPROD_TIME_TYPE; %MACRO RENAME_TIME_TYPE; %MEND RENAME_TIME_TYPE; %END; /************************************************************/ /* G-8-A-ii: Find total production quantity for each model. */ /************************************************************/ PROC MEANS NWAY DATA = COST NOPRINT; CLASS &COST_MANF &COST_PRIM &COST_MATCH &COST_TIME_PERIOD; %WHERE_STMT VAR &COST_QTY; OUTPUT OUT = TOTPRODQTY (DROP = _:) SUM = TOT_CONNUM_PROD_QTY; RUN; /****************************************************/ /* G-8-A-iii: Separate out Cost without production. */ /****************************************************/ DATA COST (DROP = TOT_CONNUM_PROD_QTY RENAME = (NOPROD_TIME_TYPE = COST_TIME_TYPE)) NOPRODUCTION (KEEP = &COST_MANF &COST_PRIM &COST_MATCH &PROD_CHARS NOPROD_TIME_TYPE &COST_TIME_PERIOD RENAME = (&COST_MANF &EQUAL_COST_MANF &NO_PROD_COST_MANF &COST_PRIM &EQUAL_COST_PRIME &NO_PROD_COST_PRIME &COST_MATCH = NO_PRODUCTION_CONNUM %RENAME_TIME_TYPE)); MERGE COST (IN = A) TOTPRODQTY (IN = B); BY &COST_MANF &COST_PRIM &COST_MATCH &COST_TIME_PERIOD; IF A; %NOPROD_TIME_TYPE IF TOT_CONNUM_PROD_QTY LE 0 THEN OUTPUT NOPRODUCTION; ELSE OUTPUT COST; RUN; PROC CONTENTS DATA = NOPRODUCTION OUT = NOPROD (KEEP = NOBS) NOPRINT; RUN; DATA _NULL_; SET NOPROD; IF _N_ = 1; IF NOBS GT 0 THEN MATCH_NOPRODS = "YES"; ELSE IF NOBS = 0 THEN MATCH_NOPRODS = "NO"; CALL SYMPUT('FIND_SURROGATES', MATCH_NOPRODS); RUN; %END; %ELSE /*************************************************/ /* G-8-B: High inflation Cost Without Production */ /*************************************************/ %IF %UPCASE(&COMPARE_BY_HIGH_INFLATION) EQ YES AND %UPCASE(&FIND_SURROGATES) = YES %THEN %DO; /****************************************************/ /* G-8-B-i: Define macro variables used in finding */ /* high inflation Cost without production. */ /****************************************************/ %GLOBAL COST_MFR_HP COST_MFR_HP_RENAME /* 8 macro variables */ COST_MFR_HP_RENAME_BACK COST_MFR_HP_SAME COST_PRIME_HP COST_PRIME_HP_RENAME COST_PRIME_HP_RENAME_BACK COST_PRIME_HP_SAME; /*------------------------------------------------------------*/ /* Create null macro variable values when CM sales */ /* manufacturer or Cost manufacturer is not relevant. */ /*------------------------------------------------------------*/ %LET COST_MFR_HP = ; /* Cost manufacturer variable */ %LET COST_MFR_HP_RENAME = ; /* Rename cost mfr variable to no-prod cost mfr variable */ %LET COST_MFR_HP_RENAME_BACK = ; /* Rename no-prod cost mfr variable to cost mfr variable */ %LET COST_MFR_HP_SAME = ; /* If no-prod cost mfr variable equal cost mfr variable */ /*---------------------------------------------------------*/ /* Assign macro variable values when CM sales manufacturer */ /* and Cost manufacturer are relevant. */ /*---------------------------------------------------------*/ %IF %UPCASE(&HMMANUF) NE NA AND %UPCASE(&COST_MANUF) NE NA %THEN /* When there is reported CM and Cost mfr */ %DO; %LET COST_MFR_HP = &COST_MANUF; %LET COST_MFR_HP_RENAME = &COST_MANUF = NO_PROD_MFR; %LET COST_MFR_HP_RENAME_BACK = NO_PROD_MFR = &COST_MANUF; %LET COST_MFR_HP_SAME = &COST_MANUF = NO_PROD_MFR; %END; /*-----------------------------------------------------------------*/ /* Assign null macro variable values when CM sales Prime/Non-prime */ /* or Cost Prime/Non-prime are not relevant. */ /*-----------------------------------------------------------------*/ %LET COST_PRIME_HP = ; /* Cost prime variable */ %LET COST_PRIME_HP_RENAME = ; /* Rename Cost prime variable to no-prod cost prime variable */ %LET COST_PRIME_HP_RENAME_BACK = ; /* Rename no-prod prime mfr variable to cost prime variable */ %LET COST_PRIME_HP_SAME = ; /* If no-prod prime variable to cost prime variable */ /*-------------------------------------------------------*/ /* Assign macro variables values when CM Prime/Non-prime */ /* and Cost Prime/Non-prime are relevant. */ /*-------------------------------------------------------*/ %IF %UPCASE(&HMPRIME) NE NA AND %UPCASE(&COST_PRIME) NE NA %THEN /* When there is reported CM and Cost prime */ %DO; %LET COST_PRIME_HP = &COST_PRIME; %LET COST_PRIME_HP_RENAME = &COST_PRIME = NO_PROD_PRIME; %LET COST_PRIME_HP_RENAME_BACK = NO_PROD_PRIME = &COST_PRIME_HP; %LET COST_PRIME_HP_SAME = &COST_PRIME = NO_PROD_PRIME; %END; /************************************************************/ /* G-8-B-ii: Find total production quantity for each model. */ /************************************************************/ PROC MEANS NWAY DATA = COST NOPRINT; CLASS &COST_MFR_HP &COST_PRIME_HP &COST_MATCH &COST_YEAR_MONTH; VAR &COST_QTY; OUTPUT OUT = TOTPRODQTY (DROP = _:) SUM = TOT_CONNUM_PROD_QTY; RUN; /****************************************************/ /* G-8-B-iii: Separate out Cost without production. */ /****************************************************/ PROC SORT DATA = COST OUT = COST; BY &COST_MFR_HP &COST_PRIME_HP &COST_MATCH &COST_YEAR_MONTH; RUN; DATA COST (DROP = TOT_CONNUM_PROD_QTY) NOPRODUCTION (KEEP = &COST_MFR_HP &COST_PRIME_HP &COST_MATCH &COST_YEAR_MONTH &COST_CHAR RENAME = (&COST_MFR_HP_RENAME &COST_PRIME_HP_RENAME &COST_MATCH = NO_PROD_CONNUM &COST_YEAR_MONTH = NO_PROD_YEAR_MONTH)); MERGE COST TOTPRODQTY; BY &COST_MFR_HP &COST_PRIME_HP &COST_MATCH &COST_YEAR_MONTH; IF TOT_CONNUM_PROD_QTY LE 0 THEN OUTPUT NOPRODUCTION; ELSE OUTPUT COST; RUN; PROC CONTENTS DATA = NOPRODUCTION OUT = NOPROD (KEEP = NOBS) NOPRINT; RUN; DATA _NULL_; SET NOPROD; IF _N_ = 1; IF NOBS GT 0 THEN MATCH_NOPRODS = "YES"; ELSE IF NOBS = 0 THEN MATCH_NOPRODS = "NO"; CALL SYMPUT('FIND_SURROGATES', MATCH_NOPRODS); RUN; %END; %MEND G8_FIND_NOPRODUCTION; /*****************************************************************/ /* G-9 ATTACH PRODUCT CHARACTERISTIC TO COST DATA, WHEN REQUIRED */ /*****************************************************************/ %MACRO G9_COST_PRODCHARS; %GLOBAL PROD_MATCH; %LET PROD_MATCH = ; %IF %UPCASE(&FIND_SURROGATES) = YES AND %UPCASE(&COST_PROD_CHARS) = NO %THEN %DO; %MACRO GETCHARS; %IF %UPCASE(&SALESDB) = HMSALES %THEN %DO; %LET PROD_MATCH = &HMCPPROD; PROC SORT DATA = USSALES NODUPKEY OUT = USCONNUMLIST (KEEP = &USCVPROD &USCHAR); BY &USCVPROD; RUN; DATA USCONNUMLIST; SET USCONNUMLIST; RENAME &USCVPROD = &HMCPPROD; %MACRO RENAMECHARS; %LET I = 1; %LET RENAMECALC = ; %DO %UNTIL (%SCAN(&USCHAR, &I, %STR( )) = %STR()); %LET RENAMECALC = &RENAMECALC RENAME %SYSFUNC(COMPRESS(%SCAN(&USCHAR,&I, %STR( )))) = %SYSFUNC(COMPRESS(%SCAN(&HMCHAR,&I, %STR( )))) %NRSTR(;); &RENAMECALC %LET I = %EVAL(&I + 1); %END; %MEND RENAMECHARS; %RENAMECHARS; RUN; PROC SORT DATA = HMSALES NODUPKEY OUT = HMCONNUMLIST (KEEP = &HMCPPROD &HMCHAR); BY &HMCPPROD; RUN; DATA CONNUMLIST; SET HMCONNUMLIST USCONNUMLIST; RUN; PROC SORT DATA = CONNUMLIST OUT = CONNUMLIST NODUPKEY; BY &HMCPPROD; RUN; %END; %IF %UPCASE(&SALESDB) = USSALES %THEN %DO; %LET PROD_MATCH = &USCVPROD; PROC SORT DATA = USSALES NODUPKEY OUT = CONNUMLIST (KEEP = &USCVPROD &USCHAR); BY &USCVPROD; RUN; %END; %MEND GETCHARS; %GETCHARS; %MACRO ATTACH_CHARS(SALES_MATCH); PROC SORT DATA = COST OUT = COST; BY &COST_MATCH &COST_TIME_PERIOD; RUN; DATA COST COST_NOT_SALES; MERGE COST (IN=A ) CONNUMLIST (IN=B RENAME=(&SALES_MATCH = &COST_MATCH)); BY &COST_MATCH; IF A & B THEN OUTPUT COST; IF A & NOT B THEN OUTPUT COST_NOT_SALES; RUN; DATA NOPRODUCTION; MERGE NOPRODUCTION (IN = A ) CONNUMLIST (IN = B RENAME = (&SALES_MATCH = NO_PRODUCTION_CONNUM)); BY NO_PRODUCTION_CONNUM; IF A & B; RUN; %MEND ATTACH_CHARS; %IF %UPCASE(&SALESDB) = HMSALES %THEN %DO; %ATTACH_CHARS(&HMCPPROD); %END; %IF %UPCASE(&SALESDB) = USSALES %THEN %DO; %ATTACH_CHARS(&USCVPROD); %END; %END; %MEND G9_COST_PRODCHARS; /**********************************************************************/ /* G-10. FILL IN MISSING LINES IN QUARTERLY COST DATA, WHEN REQUIRED */ /**********************************************************************/ /**********************************************************************************************/ /* For cases where there are time–specific costs, i.e. quarterly cost, the program assigns */ /* quarters to the CM and U.S. sales observations. The quarters are based off of the reported */ /* sale date, and first day of the POR/POI. The quarters are character, length 2, with the */ /* values '-2', '-1', '0', '1', '2', etc. This will only run if there is quarterly cost. */ /**********************************************************************************************/ %MACRO CREATE_QUARTERS(SLDT, PROGRAM); %GLOBAL HM_TIME_PERIOD US_TIME_PERIOD; %LET HM_TIME_PERIOD = ; %LET US_TIME_PERIOD = ; %IF %UPCASE(&COMPARE_BY_TIME) EQ YES %THEN %DO; %LET US_TIME_PERIOD = QTR; %IF &SALESDB = HMSALES %THEN %DO; %LET HM_TIME_PERIOD = QTR; %END; %ELSE %IF &SALESDB = USSALES %THEN %DO; %LET HM_TIME_PERIOD = HM_TIME_PERIOD; %END; FIRSTMONTH =(MONTH("&BEGINPERIOD"D)); MTH = (MONTH(&SLDT) + (YEAR(&SLDT) - YEAR("&BEGINPERIOD"D)) * 12); NQTR = (1 + (FLOOR((MTH - FIRSTMONTH) / 3))) ; QTR = STRIP(PUT(NQTR, 2.)); DROP FIRSTMONTH MTH NQTR; %END; %MEND CREATE_QUARTERS; /**********************************************************************************************************************/ /* */ /* For cases where there are time – specific costs, i.e. quarterly cost, the program takes the following steps: */ /* 1. In section G-10; */ /* a. Makes a list of CONNUMS and time periods with reported sales */ /* b. Makes a list of time periods with reported costs. */ /* c. Checks to see if there are periods with sales that have no reported costs. */ /* d. Makes a POR weight average of the cost database by CONNUM. */ /* 2. In Section G-11, if there are periods that have sales that do not have any reported costs: */ /* a. On a CONNUM specific basis, pull the closest period of production into the period that needs production. */ /* Keep the direct materials costs, and index them to adjust those costs according to the period. */ /* b. Apply the POR/I weight average ‘conversion costs’ i.e. the non-direct materials costs, to each CONNUM. */ /* 3. In Section G-12; if there CONNUMS with no production in a specific period, but production in other period(s): */ /* a. Find the most similar CONNUM with production in the period and assign its direct materials costs as */ /* surrogate to the CONNUM(s) with no production. */ /* b. Assign the POR/I weight average conversion costs to those CONNUMS with no production in the period. */ /* 4. In Section G-13; if there are CONNUMS with sales in the POR/I and no production anywhere in the POR/I: */ /* a. Assign the most similar CONNUM’s cost from within the period as the surrogate for the CONNUM with no costs. */ /* */ /**********************************************************************************************************************/ %MACRO G10_TIME_PROD_LIST; OPTIONS MPRINT SYMBOLGEN; %IF %UPCASE(&COMPARE_BY_TIME) EQ YES %THEN %DO; %GLOBAL NOPROD_CHAR DIF_CHAR RENAME_NOPROD RENAME_DIF RENAME_HMCHAR RENAME_USCHAR ALLCOSTVARS NOPROD_TO_CHAR MFRZ LIST_TIMES ZERO_PROD_TIME NEEDTIMELST NV_TYPE SUM_DIRMAT_VARS REPLACE_INDEXED_DIRMATS NOPRDDMT CLSTPRDDMT PCTCHADMT RDMT HM_TIMES COSTPROD; %MACRO SCENERIO_MCRS; %LET RENAME_USCHAR = ; /* Scenario 1: CM, COP DB has COST_CHARS */ %MACRO HM_COP_HAS_CHARS; DATA CHAR_CHANGE (DROP = I); DO I = 1 TO COUNTW("&COST_CHAR"); NOPROD_CHAR = STRIP(CATS(SCAN("&COST_CHAR", I), "_NOPROD")); DIF_CHAR = STRIP(CATS(SCAN("&COST_CHAR", I), "_DIF")); RENAME_NOPROD = STRIP(CATS(SCAN("&COST_CHAR", I), "=", NOPROD_CHAR)); RENAME_DIF = STRIP(CATS(SCAN("&COST_CHAR", I), "=", DIF_CHAR)); RENAMEMATCHUS= STRIP(CATS(SCAN("&USCHAR", I), "=", SCAN("&COST_CHAR", I))); NOPROD_TO_CHAR= STRIP(CATS(NOPROD_CHAR, "=", SCAN("&COST_CHAR", I))); RENAMEMATCHHM = STRIP(CATS(SCAN("&HMCHAR", I), "=", SCAN("&COST_CHAR", I))); OUTPUT; END; RUN; PROC SQL NOPRINT; SELECT NOPROD_CHAR, DIF_CHAR, RENAME_NOPROD, RENAME_DIF, RENAMEMATCHHM, RENAMEMATCHUS, NOPROD_TO_CHAR INTO :NOPROD_CHAR SEPARATED BY " ", :DIF_CHAR SEPARATED BY " ", :RENAME_NOPROD SEPARATED BY " ", :RENAME_DIF SEPARATED BY " ", :RENAME_HMCHAR SEPARATED BY " ", :RENAME_USCHAR SEPARATED BY " ", :NOPROD_TO_CHAR SEPARATED BY " " FROM CHAR_CHANGE; QUIT; %MEND HM_COP_HAS_CHARS; /* Scenario 2: CM, COP DB does not have COST_CHARS */ %MACRO HM_COP_NOTHAVE_CHARS; DATA CHAR_CHANGE (DROP = I); DO I = 1 TO COUNTW("&HMCHAR"); NOPROD_CHAR = STRIP(CATS(SCAN("&HMCHAR", I), "_NOPROD")); DIF_CHAR = STRIP(CATS(SCAN("&HMCHAR", I), "_DIF")); RENAME_NOPROD = STRIP(CATS(SCAN("&HMCHAR", I), "=", NOPROD_CHAR)); RENAME_DIF = STRIP(CATS(SCAN("&HMCHAR", I), "=", DIF_CHAR)); RENAMEMATCHUS= STRIP(CATS(SCAN("&USCHAR", I), "=", SCAN("&HMCHAR", I))); NOPROD_TO_CHAR= STRIP(CATS(NOPROD_CHAR, "=", SCAN("&HMCHAR", I))); OUTPUT; END; RUN; PROC SQL NOPRINT; SELECT NOPROD_CHAR, DIF_CHAR, RENAME_NOPROD, RENAME_DIF, RENAMEMATCHUS, NOPROD_TO_CHAR INTO :NOPROD_CHAR SEPARATED BY " ", :DIF_CHAR SEPARATED BY " ", :RENAME_NOPROD SEPARATED BY " ", :RENAME_DIF SEPARATED BY " ", :RENAME_USCHAR SEPARATED BY " ", :NOPROD_TO_CHAR SEPARATED BY " " FROM CHAR_CHANGE; QUIT; %LET RENAME_HMCHAR = ; %MEND HM_COP_NOTHAVE_CHARS; /* Scenario 3: US (CV), COP has COST_CHARS */ %MACRO US_COP_HAS_CHARS; DATA CHAR_CHANGE (DROP = I); DO I = 1 TO COUNTW("&COST_CHAR"); NOPROD_CHAR = STRIP(CATS(SCAN("&COST_CHAR", I), "_NOPROD")); DIF_CHAR = STRIP(CATS(SCAN("&COST_CHAR", I), "_DIF")); RENAME_NOPROD = STRIP(CATS(SCAN("&COST_CHAR", I), "=", NOPROD_CHAR)); RENAME_DIF = STRIP(CATS(SCAN("&COST_CHAR", I), "=", DIF_CHAR)); RENAMEMATCHUS= STRIP(CATS(SCAN("&USCHAR", I), "=", SCAN("&COST_CHAR", I))); NOPROD_TO_CHAR= STRIP(CATS(NOPROD_CHAR, "=", SCAN("&COST_CHAR", I))); OUTPUT; END; RUN; PROC SQL NOPRINT; SELECT NOPROD_CHAR, DIF_CHAR, RENAME_NOPROD, RENAME_DIF, RENAMEMATCHUS, NOPROD_TO_CHAR INTO :NOPROD_CHAR SEPARATED BY " ", :DIF_CHAR SEPARATED BY " ", :RENAME_NOPROD SEPARATED BY " ", :RENAME_DIF SEPARATED BY " ", :RENAME_USCHAR SEPARATED BY " ", :NOPROD_TO_CHAR SEPARATED BY " " FROM CHAR_CHANGE; QUIT; %MEND US_COP_HAS_CHARS; /* Scenario 4: US (CV), COP DB does not have COST_CHARS */ %MACRO US_COP_NOTHAVE_CHARS; %LET COST_CHAR = ; DATA CHAR_CHANGE (DROP = I); DO I = 1 TO COUNTW("&USCHAR"); NOPROD_CHAR = STRIP(CATS(SCAN("&USCHAR", I), "_NOPROD")); DIF_CHAR = STRIP(CATS(SCAN("&USCHAR", I), "_DIF")); RENAME_NOPROD = STRIP(CATS(SCAN("&USCHAR", I), "=", NOPROD_CHAR)); RENAME_DIF = STRIP(CATS(SCAN("&USCHAR", I), "=", DIF_CHAR)); NOPROD_TO_CHAR= STRIP(CATS(NOPROD_CHAR, "=", SCAN("&USCHAR", I))); OUTPUT; END; RUN; PROC SQL NOPRINT; SELECT NOPROD_CHAR, DIF_CHAR, RENAME_NOPROD, RENAME_DIF, NOPROD_TO_CHAR INTO :NOPROD_CHAR SEPARATED BY " ", :DIF_CHAR SEPARATED BY " ", :RENAME_NOPROD SEPARATED BY " ", :RENAME_DIF SEPARATED BY " ", :NOPROD_TO_CHAR SEPARATED BY " " FROM CHAR_CHANGE; QUIT; %MEND US_COP_NOTHAVE_CHARS; %MACRO MAKE_HMLIST; PROC SORT DATA = HMSALES (KEEP = &HM_TIME_PERIOD &SALES_COST_MANF &HMCONNUM &HMCHAR) OUT = HM_TIMES (RENAME = (&HM_TIME_PERIOD = &COST_TIME_PERIOD &HMCONNUM = &COST_MATCH &SALES_COST_MANF &EQUAL_COST_MANF &COST_MANF &RENAME_HMCHAR )) NODUPKEY; BY &SALES_COST_MANF &HM_TIME_PERIOD &HMCONNUM; RUN; %MEND; %IF &SALESDB = HMSALES %THEN %DO; %IF &COST_PROD_CHARS NE NO %THEN %DO; %HM_COP_HAS_CHARS %LET COSTPROD = &COST_CHAR; %END; %ELSE %DO; %HM_COP_NOTHAVE_CHARS %LET COSTPROD = &HMCHAR; %END; %MAKE_HMLIST %READ_US %LET HM_TIMES = HM_TIMES; /* To include CM sales in the times list */ %END; %ELSE %IF &SALESDB = USSALES %THEN %DO; %GLOBAL COST_MANF COST_PRIM COP_MANF_OUT EQUAL_COST_MANF US_SALES_COST_MANF; /*-----------------------------------------------------------------*/ /* Define macro variables and set their default values to nothing. */ /*-----------------------------------------------------------------*/ %LET COST_MANF = ; %LET COP_MANF_OUT = ; %LET EQUAL_COST_MANF = ; %LET US_SALES_COST_MANF = ; %IF %UPCASE(&COST_MANUF) NE NA %THEN %DO; %LET COST_MANF = &COST_MANUF; %LET COP_MANF_OUT = COST_MANUF; %LET EQUAL_COST_MANF = = ; %LET FIRST_COST_MANF = FIRST.&&COST_MANF OR; %LET US_SALES_COST_MANF = &USMANF; %END; %IF %UPCASE(&COST_PRIME) = NA %THEN %DO; %LET COST_PRIM = ; %END; %IF %UPCASE(&COST_PRIME) NE NA %THEN %DO; %LET COST_PRIM = &COST_PRIME; %END; %IF &COST_PROD_CHARS NE NO %THEN %DO; %US_COP_HAS_CHARS %LET COSTPROD = &COST_CHAR; %END; %ELSE %DO; %US_COP_NOTHAVE_CHARS %LET COSTPROD = &USCHAR; %END; %LET HM_TIMES = ; /* No CM sales for the times list */ %END; %MEND SCENERIO_MCRS; %SCENERIO_MCRS PROC SORT DATA = USSALES (KEEP = &US_TIME_PERIOD &US_SALES_COST_MANF &USCVPROD &USCHAR) OUT = US_TIMES (RENAME = (&US_TIME_PERIOD = &COST_TIME_PERIOD &USCVPROD = &COST_MATCH &US_SALES_COST_MANF &EQUAL_COST_MANF &COST_MANF &RENAME_USCHAR)) NODUPKEY; BY &US_SALES_COST_MANF &US_TIME_PERIOD &USCVPROD; RUN; DATA ALL_SALES_TIME_PERIODS; SET &HM_TIMES US_TIMES; SALESTIME = &COST_TIME_PERIOD; RUN; /* Creates a list of quarters with sales */ PROC SORT DATA = ALL_SALES_TIME_PERIODS (DROP = &COST_CHAR) OUT = SALES_TIME_PERIODS NODUPKEY; BY &COST_MANF &COST_TIME_PERIOD; RUN; PROC SQL NOPRINT ; SELECT DISTINCT(&COST_TIME_PERIOD) INTO :LIST_TIMES SEPARATED BY " " FROM SALES_TIME_PERIODS; QUIT; /* Creates a list of manufacturers, quarters, and CONNUMS */ PROC SORT DATA = ALL_SALES_TIME_PERIODS OUT = MFR_TIME_CONN_LIST (DROP = SALESTIME) NODUPKEY; BY &COST_MANF &COST_TIME_PERIOD &COST_MATCH; RUN; /*-------------------------------------------------------------------*/ /* Make a list of all time periods with production in the cost data. */ /*-------------------------------------------------------------------*/ PROC MEANS NWAY DATA = COST NOPRINT; WHERE &COST_QTY GT 0; CLASS &COST_MANF &COST_TIME_PERIOD; VAR &COST_QTY; OUTPUT OUT = COST_TIMES (DROP = _:) SUM = ; RUN; DATA COST_TIMES; SET COST_TIMES; COST_TIME = &COST_TIME_PERIOD; RUN; DATA NEED_COST_TIMES NEED_COST_TIMES_LIST (KEEP = NEED_TIME &COST_MANF); MERGE SALES_TIME_PERIODS(IN = A) COST_TIMES (IN = B); FORMAT NEED_TIME $9.; BY &COST_MANF &COST_TIME_PERIOD; IF COST_TIME = "" THEN NEED_TIME = &COST_TIME_PERIOD; OUTPUT NEED_COST_TIMES; IF COST_TIME = "" THEN DO; OUTPUT NEED_COST_TIMES_LIST; CALL SYMPUTX("ZERO_PROD_TIME", 'YES'); END; RUN; %LET NEEDTIMELST = ; PROC SQL NOPRINT; SELECT DISTINCT(QUOTE(NEED_TIME)) INTO :NEEDTIMELST SEPARATED BY "," FROM NEED_COST_TIMES_LIST; QUIT; PROC PRINT DATA = NEED_COST_TIMES LABEL; VAR &COST_MANF SALESTIME COST_TIME NEED_TIME; LABEL SALESTIME = "PERIODS WITH REPORTED SALES" COST_TIME = "PERIODS WITH REPORTED PRODUCTION" NEED_TIME = "PERIODS WITH SALES WITHOUT REPORTED PRODUCTION"; TITLE3 "TIME PERIODS WITH SALES BUT NO REPORTED PRODUCTION"; RUN; /* Create POR weight averaged cost dataset */ PROC MEANS NWAY DATA = COST NOPRINT; WHERE &COST_TIME_PERIOD IN (&TIME_INSIDE_POR); ID &COST_CHAR; CLASS &COST_MANF &COST_MATCH; VAR _NUMERIC_; WEIGHT &COST_QTY; OUTPUT OUT = POR_COST (DROP = _:) MEAN = ; RUN; PROC MEANS NWAY DATA = COST NOPRINT; WHERE &COST_TIME_PERIOD IN (&TIME_INSIDE_POR); CLASS &COST_MANF &COST_MATCH; VAR &COST_QTY; OUTPUT OUT = POR_COST_QTYS (DROP = _:) SUM =; RUN; DATA POR_COST TEST; MERGE POR_COST (IN = A) POR_COST_QTYS (IN = B); BY &COST_MANF &COST_MATCH; IF A AND B THEN OUTPUT POR_COST; ELSE OUTPUT TEST; RUN; PROC CONTENTS DATA = COST NOPRINT OUT = ALLCOSTVARS (KEEP = NAME VARNUM); RUN; PROC SORT DATA = ALLCOSTVARS OUT = ALLCOSTVARS; BY VARNUM; RUN; PROC SQL NOPRINT; SELECT NAME INTO :ALLCOSTVARS SEPARATED BY " " FROM ALLCOSTVARS; QUIT; %IF %UPCASE(&FIND_SURROGATES) = YES %THEN %DO; PROC PRINT DATA = POR_COST (OBS = &PRINTOBS); TITLE3 "PERIOD WIDE WEIGHT AVERAGED COSTS"; RUN; %END; %END; %MEND G10_TIME_PROD_LIST; /***************************************************************/ /* G-11 CREATE COST DATABASE FOR PERIODS WITH ZERO PRODUCTION, */ /* BUT SALES IN QUARTERLY COST SITUATIONS */ /***************************************************************/ %MACRO G11_CREATE_TIME_COST_DB; %IF %UPCASE(&COMPARE_BY_TIME) = YES %THEN %DO; %IF &COST_MANUF NE NA %THEN %DO; %MACRO NTC_MFR; (RENAME = &COST_MANF = NTC_&COST_MANF) %MEND; %MACRO WHERENTCMFR; WHERE &COST_MANF = NTC_&COST_MANF; %MEND; %END; %ELSE %DO; %MACRO NTC_MFR; %MEND; %MACRO WHERENTCMFR; %MEND; %END; /*****************************************************************************/ /* Pull closest quarter into need quarter for the direct material variables. */ /*****************************************************************************/ /*********************************************************************************************/ /* CREATE THE INDEXING CALCULATIONS */ /* NO_PROD_DIRMAT = INPUT(PUT(NEED_TIME, $DIRMAT_INPUT.), 8.); */ /* CLOSEST_PROD_DIRMAT= INPUT(PUT(&COST_TIME_PERIOD, $DIRMAT_INPUT.), 8.); */ /* PERCENT_CHANGE_DIRMAT = (NO_PROD_DIRMAT - CLOSEST_PROD_DIRMAT) / CLOSEST_PROD_DIRMAT; */ /* RDIRMAT = DIRMAT * (1 + PERCENT_CHANGE_DIRMAT); */ /*********************************************************************************************/ DATA DIRMAT_VARS_CHANGE (DROP = I); DO I = 1 TO COUNTW("&DIRMAT_VARS"); DMT_VRS = STRIP(SCAN("&DIRMAT_VARS", I)); R_DRMT_VRS = STRIP(CATS("R",SCAN("&DIRMAT_VARS", I))); RNMAME_RDRIMATS = STRIP(CATS(SCAN("&DIRMAT_VARS", I), "=", R_DRMT_VRS,";")); NOPRDDMT = CATS("NO_PROD_",DMT_VRS, " = INPUT(PUT(NEED_TIME, $", DMT_VRS, "_INPUT.), 8.)"); CLSTPRDDMT = CATS("CLOSEST_PROD_",DMT_VRS," = INPUT(PUT(&COST_TIME_PERIOD, $",DMT_VRS, "_INPUT.), 8.)"); PCTCHADMT = CATS("PERCENT_CHANGE_",DMT_VRS, " = (NO_PROD_", DMT_VRS, " - CLOSEST_PROD_", DMT_VRS, ") / CLOSEST_PROD_", DMT_VRS); RDMT = CATS("R", DMT_VRS, " = ", DMT_VRS," * (1 + PERCENT_CHANGE_", DMT_VRS, ")"); OUTPUT; END; RUN; PROC SQL NOPRINT; SELECT DMT_VRS, RNMAME_RDRIMATS, NOPRDDMT, CLSTPRDDMT, PCTCHADMT, RDMT INTO :SUM_DIRMAT_VARS SEPARATED BY ",", :REPLACE_INDEXED_DIRMATS SEPARATED BY " ", :NOPRDDMT SEPARATED BY "; ", :CLSTPRDDMT SEPARATED BY "; ", :PCTCHADMT SEPARATED BY "; ", :RDMT SEPARATED BY "; " FROM DIRMAT_VARS_CHANGE ; QUIT; /* Pull closest quarter into needed quarter for DIRMAT variables */ %IF &NEEDTIMELST NE ( ) %THEN %DO; DATA NEED_TIMES_COST; SET COST; DO J = 1 TO LAST; SET NEED_COST_TIMES_LIST %NTC_MFR POINT = J NOBS = LAST; TIME_DIF= ABS(NEED_TIME - &COST_TIME_PERIOD); OUTPUT; END; RUN; PROC SORT DATA = NEED_TIMES_COST OUT = NEED_TIMES_COST; BY NEED_TIME &COST_MANF &COST_MATCH TIME_DIF; RUN; DATA NO_PROD_TIMES_COST; SET NEED_TIMES_COST; %WHERENTCMFR; BY NEED_TIME &COST_MANF &COST_MATCH TIME_DIF; IF FIRST.&COST_MATCH THEN OUTPUT NO_PROD_TIMES_COST; RUN; /*******************************************************************************************/ /* Use the indexing calculations from Section G10. For each indexed cost variable, */ /* the calculations should be: */ /* */ /* NO_PROD_DIRMAT = INPUT(PUT(NEED_TIME, $DIRMAT_INPUT.), 8.); */ /* CLOSEST_PROD_DIRMAT = INPUT(PUT(&COST_TIME_PERIOD, $DIRMAT_INPUT.), 8.); */ /* PERCENT_CHANGE_DIRMAT = (NO_PROD_DIRMAT - CLOSEST_PROD_DIRMAT) / CLOSEST_PROD_DIRMAT; */ /* RDIRMAT = DIRMAT * (1 + PERCENT_CHANGE_DIRMAT); */ /*******************************************************************************************/ DATA NO_PROD_TIMES_COST; SET NO_PROD_TIMES_COST; &NOPRDDMT; &CLSTPRDDMT; &PCTCHADMT; &RDMT; %LET REVISED_DIRMAT_VARS = R%SYSFUNC(TRANWRD(%QUOTE(&SUM_DIRMAT_VARS), %STR(,), %STR(, R))); RUN; PROC PRINT DATA = NO_PROD_TIMES_COST (OBS = &PRINTOBS); VAR &ALLCOSTVARS NEED_TIME TIME_DIF NO_PROD: CLOSEST_PROD: PERCENT_CHANGE: R:; TITLE3 "DIRECT MATERIALS ADJUSTMENT CALCULATIONS (&REVISED_DIRMAT_VARS)"; TITLE4 "FOR COSTS IN PERIODS WITHOUT PRODUCTION"; RUN; DATA NO_PROD_TIMES_COST (KEEP = &ALLCOSTVARS); SET NO_PROD_TIMES_COST; &REPLACE_INDEXED_DIRMATS; &COST_TIME_PERIOD = NEED_TIME; RUN; /***************************************************************************************/ /* Replace time period specific conversion costs with period average conversion costs. */ /***************************************************************************************/ PROC SORT DATA = NO_PROD_TIMES_COST (KEEP = &DIRMAT_VARS &COST_MATCH &COST_MANF &COST_TIME_PERIOD); BY &COST_MANF &COST_MATCH; RUN; DATA POR_COST_2; SET POR_COST; SUMDURMATS = SUM(&SUM_DIRMAT_VARS); REDUCED_&TOTCOM = &TOTCOM - SUMDURMATS; %LET DIRMAT_VARS_WITHOUT_COMMAS = %SYSFUNC(TRANWRD(%QUOTE(&SUM_DIRMAT_VARS), %STR(,), %STR( ))); RUN; PROC PRINT DATA = POR_COST_2 (OBS = &PRINTOBS); VAR &COST_MANF &COST_MATCH &TOTCOM &DIRMAT_VARS_WITHOUT_COMMAS REDUCED_&TOTCOM; TITLE3 "REDUCED TOTAL COST OF MANUFACTURING (REDUCED_&TOTCOM)"; TITLE4 "WITH DIRECT MATERIAL VARIABLES NEEDING AVERAGE PURCHASE COSTS (&SUM_DIRMAT_VARS)"; TITLE5 "BACKED OUT OF THE ORIGINAL TOTAL COST OF MANUFACTURING (&TOTCOM)"; RUN; PROC SORT DATA = POR_COST_2 (DROP = &DIRMAT_VARS SUMDURMATS) OUT = POR_COST_2; BY &COST_MANF &COST_MATCH; RUN; DATA NO_PROD_TIMES_COST TEST; MERGE NO_PROD_TIMES_COST (IN = A) POR_COST_2(IN = B); BY &COST_MANF &COST_MATCH; IF A AND NOT B THEN OUTPUT TEST; ELSE IF A THEN OUTPUT NO_PROD_TIMES_COST; RUN; DATA NO_PROD_TIMES_COST; SET NO_PROD_TIMES_COST; SUM_INDEXED_DIRMATS = SUM(&SUM_DIRMAT_VARS); REVISED_&TOTCOM = REDUCED_&TOTCOM + SUM_INDEXED_DIRMATS; RUN; PROC PRINT DATA = NO_PROD_TIMES_COST (OBS = &PRINTOBS) SPLIT = '*'; LABEL SUM_INDEXED_DIRMATS = "SUM OF AVERAGE PURCHASE COSTS"; TITLE3 "SELECTION OF COSTS IN PERIODS WITHOUT PRODUCTION"; TITLE4 "WITH REVISED DIRECT MATERIAL VARIABLES WITH AVERAGE PURCHASE COSTS (&SUM_DIRMAT_VARS)"; TITLE5 "ADDED TO REDUCED TOTAL COST OF MANUFACTURING (REDUCED_&TOTCOM)"; RUN; DATA COST; SET COST NO_PROD_TIMES_COST (DROP = &TOTCOM REDUCED_&TOTCOM RENAME = REVISED_&TOTCOM = &TOTCOM); RUN; %END; %END; %MEND G11_CREATE_TIME_COST_DB; /**************************************************************/ /* G-12 CREATE COST FOR CONNUMS WITH NO PRODUCTION IN PERIODS */ /* WITH PRODUCTION IN QUARTERLY COST SITUATIONS */ /**************************************************************/ %MACRO G12_ZERO_PROD_IN_PERIODS; %IF %UPCASE(&COMPARE_BY_TIME) EQ YES AND %UPCASE(&FIND_SURROGATES) = YES %THEN %DO; %IF &COST_MANUF NE NA %THEN %DO; %MACRO MFREQUAL; AND &COST_MANF = NTC_&COST_MANF %MEND MFREQUAL; %MACRO RENAMEMFR; &COST_MANF = NTC_&COST_MANF %MEND RENAMEMFR; %MACRO NTC_MANF; NTC_&COST_MANF %MEND NTC_MANF; %END; %ELSE %DO; %MACRO MFREQUAL; %MEND MFREQUAL; %MACRO RENAMEMFR; %MEND RENAMEMFR; %MACRO NTC_MANF; %MEND NTC_MANF; %END; PROC SORT DATA = NEED_COST_TIMES (DROP = &COST_MATCH NEED_TIME RENAME = (%RENAMEMFR COST_TIME = NO_PRODUCTION_QUARTER)) OUT = NEED_COST_TIMES; BY %NTC_MANF NO_PRODUCTION_QUARTER; WHERE NO_PRODUCTION_QUARTER NE " "; RUN; PROC SORT DATA = NOPRODUCTION %NTC_MFR OUT = NOPRODUCTION; BY %NTC_MANF NO_PRODUCTION_QUARTER NO_PRODUCTION_CONNUM; RUN; DATA ZERO_PROD TEST; MERGE NOPRODUCTION (IN = A DROP = NOPROD_TIME_TYPE) NEED_COST_TIMES (IN = B); BY %NTC_MANF NO_PRODUCTION_QUARTER; IF A AND B THEN OUTPUT ZERO_PROD; ELSE OUTPUT TEST; RUN; DATA ZERO_PROD_SIMCOST (DROP = I); SET ZERO_PROD (RENAME = (&RENAME_NOPROD)); DO J = 1 TO LAST; SET COST (KEEP = &COST_MATCH &COSTPROD &COST_TIME_PERIOD &COST_MANF &DIRMAT_VARS) POINT = J NOBS = LAST; IF &COST_TIME_PERIOD = NO_PRODUCTION_QUARTER %MFREQUAL THEN DO; ARRAY NOPROD(*) &NOPROD_CHAR; ARRAY COSTPROD (*) &COSTPROD; ARRAY DIFCHR (*) &DIF_CHAR; DO I = 1 TO DIM(DIFCHR); DIFCHR(I) = ABS(INPUT(NOPROD(I), 8.) - INPUT(COSTPROD(I), 8.)); END; OUTPUT ZERO_PROD_SIMCOST; END; END; RUN; PROC SORT DATA = ZERO_PROD_SIMCOST OUT = ZERO_PROD_SIMCOST; BY &COST_MANF &COST_TIME_PERIOD NO_PRODUCTION_CONNUM &DIF_CHAR; RUN; DATA ZERO_PROD_SIMCOST_TOP5 ZERO_PROD_SIMCOST_TOP1 (DROP = &DIF_CHAR &NOPROD_CHAR CHOICE NO_PRODUCTION_QUARTER &COST_MATCH %NTC_MANF RENAME = (NO_PRODUCTION_CONNUM = &COST_MATCH)); SET ZERO_PROD_SIMCOST; BY &COST_MANF &COST_TIME_PERIOD NO_PRODUCTION_CONNUM &DIF_CHAR; IF FIRST.NO_PRODUCTION_CONNUM THEN CHOICE = 0; CHOICE + 1; IF CHOICE = 1 THEN DO; OUTPUT ZERO_PROD_SIMCOST_TOP1; END; IF CHOICE LE 5 THEN OUTPUT ZERO_PROD_SIMCOST_TOP5; RUN; PROC SORT DATA = ZERO_PROD_SIMCOST_TOP5 OUT = ZERO_PROD_SIMCOST_TOP5; BY &COST_TIME_PERIOD NO_PRODUCTION_CONNUM; RUN; PROC PRINT DATA = ZERO_PROD_SIMCOST_TOP5 (OBS = &PRINTOBS); BY &COST_TIME_PERIOD NO_PRODUCTION_CONNUM; PAGEBY NO_PRODUCTION_CONNUM; VAR %NTC_MANF &COST_MATCH &COST_MANF &DIF_CHAR CHOICE &DIRMAT_VARS; TITLE3 "CHECK OF 5 SIMILIAR MATCHES FOR ASSIGNING DIRECT MATERIALS TO CONNUMS WITHOUT PRODUCTION IN PERIODS WITH PRODUCTION"; RUN; /* Add por weight averaged conversion costs to similar list */ DATA POR_COST_3; SET POR_COST; SUMDURMATS = SUM(&SUM_DIRMAT_VARS); R&TOTCOM = &TOTCOM - SUMDURMATS; RUN; PROC SORT DATA = ZERO_PROD_SIMCOST_TOP1 (KEEP = &COST_TIME_PERIOD &COST_MANF &COST_MATCH &DIRMAT_VARS) OUT = ZERO_PROD_SIMCOST_TOP1; BY &COST_MANF &COST_MATCH; RUN; PROC PRINT DATA = POR_COST_3 (OBS = &PRINTOBS); TITLE3 "SAMPLE OF PERIOD-WIDE WEIGHT AVERAGED CONVERSION COSTS"; TITLE4 "WITH &TOTCOM REDUCED BY DIRECT MATERIAL VARIABLES (&DIRMAT_VARS)"; RUN; PROC SORT DATA = POR_COST_3 OUT = POR_CONV_COST (DROP = &DIRMAT_VARS SUMDURMATS &TOTCOM); BY &COST_MANF &COST_MATCH; RUN; DATA ZERO_PROD_ALLCOST; MERGE ZERO_PROD_SIMCOST_TOP1 (IN = A) POR_CONV_COST (IN = B); BY &COST_MANF &COST_MATCH; IF A AND B THEN OUTPUT ZERO_PROD_ALLCOST; RUN; DATA ZERO_PROD_ALLCOST (DROP = R&TOTCOM SUMDURMATS); SET ZERO_PROD_ALLCOST; SUMDURMATS = SUM(&SUM_DIRMAT_VARS); &TOTCOM = R&TOTCOM + SUMDURMATS; COST_TIME_TYPE = 'Q2'; RUN; PROC PRINT DATA = ZERO_PROD_ALLCOST (OBS = &PRINTOBS); TITLE3 "SAMPLE OF COSTS FOR CONNUMS WITH ZERO PRODUCTION WITHIN PERIODS WITH PRODUCTION"; TITLE4 "WITH SURROGATE DIRECT MATERIAL VARIABLES (&DIRMAT_VARS) FOUND IN THE SAME QUARTER ADDED TO REDUCED &TOTCOM"; RUN; /* Append to the total cost dataset */ DATA COST; SET COST; COST_TIME_TYPE = 'Q1'; RUN; DATA COST; SET COST ZERO_PROD_ALLCOST; FORMAT COST_TIME_TYPE $TIMETYPE.; RUN; %END; %MEND G12_ZERO_PROD_IN_PERIODS; /*************************************************************/ /* G-13 CREATE COST FOR SALES WITHOUT PRODUCTION IN REPORTED */ /* TIME PERIOD(S) IN QUARTERLY COST SITUATIONS */ /*************************************************************/ %MACRO G13_CREATE_COST_PROD_TIMES; %IF %UPCASE(&COMPARE_BY_TIME) EQ YES AND %UPCASE(&FIND_SURROGATES) = YES %THEN %DO; %IF &COST_MANUF NE NA %THEN %DO; %MACRO MFREQUAL; AND &COST_MANF = ISNC_&COST_MANF %MEND MFREQUAL; %MACRO RENAMEMFR; &COST_MANF = ISNC_&COST_MANF %MEND RENAMEMFR; %MACRO ISNC_MANF; ISNC_&COST_MANF %MEND ISNC_MANF; %END; %ELSE %DO; %MACRO MFREQUAL; %MEND MFREQUAL; %MACRO RENAMEMFR; %MEND RENAMEMFR; %MACRO ISNC_MANF; %MEND ISNC_MANF; %END; PROC SORT DATA = COST; BY &COST_TIME_PERIOD &COST_MANF &COST_MATCH; RUN; PROC SORT DATA = ALL_SALES_TIME_PERIODS (KEEP = &COST_MANF &COST_TIME_PERIOD &COST_MATCH &COSTPROD) OUT = ALL_SALES_TIME_PERIODS; BY &COST_TIME_PERIOD &COST_MANF &COST_MATCH; RUN; DATA IN_SALES_NOT_COST (KEEP = &COST_MANF &COST_TIME_PERIOD &COST_MATCH &COSTPROD); MERGE ALL_SALES_TIME_PERIODS (IN = A) COST (IN = B); BY &COST_TIME_PERIOD &COST_MANF &COST_MATCH; IF A AND NOT B THEN OUTPUT IN_SALES_NOT_COST; RUN; DATA ISNC_SIMCOST (DROP = I); SET IN_SALES_NOT_COST (RENAME = (&RENAME_NOPROD &COST_TIME_PERIOD = ISNC_&COST_TIME_PERIOD &COST_MATCH = ISNC_&COST_MATCH %RENAMEMFR)); DO J = 1 TO LAST; SET COST POINT = J NOBS = LAST; IF &COST_TIME_PERIOD = ISNC_&COST_TIME_PERIOD %MFREQUAL THEN DO; ARRAY NOPROD(*) &NOPROD_CHAR; ARRAY COSTPROD (*) &COSTPROD; ARRAY DIFCHR (*) &DIF_CHAR; DO I = 1 TO DIM(DIFCHR); DIFCHR(I) = ABS(INPUT(NOPROD(I), 8.) - INPUT(COSTPROD(I), 8.)); END; COST_TIME_TYPE = 'Q2'; OUTPUT ISNC_SIMCOST; END; END; RUN; PROC SORT DATA = ISNC_SIMCOST; BY &COST_MANF &COST_TIME_PERIOD ISNC_&COST_MATCH &DIF_CHAR; RUN; DATA ISNC_SIMCOST_TOP5 ISNC_SIMCOST_TOP1 (DROP = &DIF_CHAR &NOPROD_CHAR CHOICE &COST_MATCH %ISNC_MANF ISNC_&COST_TIME_PERIOD RENAME = (ISNC_&COST_MATCH = &COST_MATCH)); SET ISNC_SIMCOST; BY &COST_MANF &COST_TIME_PERIOD ISNC_&COST_MATCH &DIF_CHAR; IF FIRST.ISNC_&COST_MATCH THEN CHOICE = 0; CHOICE + 1; IF CHOICE = 1 THEN DO; OUTPUT ISNC_SIMCOST_TOP1; END; IF CHOICE LE 5 THEN OUTPUT ISNC_SIMCOST_TOP5; RUN; PROC SORT DATA = ISNC_SIMCOST_TOP5 OUT = ISNC_SIMCOST_TOP5; BY ISNC_&COST_MATCH; RUN; PROC PRINT DATA = ISNC_SIMCOST_TOP5 (OBS = &PRINTOBS); BY ISNC_&COST_MATCH; PAGEBY ISNC_&COST_MATCH; VAR &COST_TIME_PERIOD ISNC_&COST_MATCH %ISNC_MANF &COST_MATCH &COST_MANF &DIF_CHAR CHOICE &DIRMAT_VARS; TITLE3 "CHECK OF 5 SIMILIAR MATCHES FOR SALES WITHOUT PRODUCTION IN PERIODS WITH PRODUCTION"; RUN; /* Append to the total cost dataset */ DATA COST; SET COST ISNC_SIMCOST_TOP1 (IN = B); IF B THEN COST_TIME_TYPE = 'Q2'; FORMAT COST_TIME_TYPE $TIMETYPE.; RUN; PROC SORT DATA = COST NODUPKEY OUT = CTEST DUPOUT = CDUPS; BY &COST_MANF &COST_TIME_PERIOD &COST_MATCH; RUN; %END; %MEND G13_CREATE_COST_PROD_TIMES; /************************/ /* G-14: HIGH INFLATION */ /************************/ /*************************************************************/ /* Create the variable YEARMONTHH or YEARMONTHU representing */ /* the year and month of the sales based on the sale date. */ /*************************************************************/ %MACRO CREATE_YEAR_MONTH(SALEDATE, PROGRAM); %IF %UPCASE(&COMPARE_BY_HIGH_INFLATION) EQ YES %THEN %DO; %IF %UPCASE(&SALESDB = HMSALES) %THEN %DO; LENGTH YEARMONTHH $6.; YEARMONTHH = CATS(PUT(YEAR(&SALEDATE), 4.), PUT(MONTH(&SALEDATE), Z2.)); %END; %ELSE %IF %UPCASE(&SALESDB = DOWNSTREAM) %THEN %DO; LENGTH YEARMONTHH $6.; YEARMONTHH = CATS(PUT(YEAR(&SALEDATE), 4.), PUT(MONTH(&SALEDATE), Z2.)); %END; %ELSE %IF %UPCASE(&SALESDB) = USSALES %THEN %DO; LENGTH YEARMONTHU $6.; YEARMONTHU = CATS(PUT(YEAR(&SALEDATE), 4.), PUT(MONTH(&SALEDATE), Z2.)); %END; %END; %MEND CREATE_YEAR_MONTH; %MACRO G14_HIGH_INFLATION; %IF %UPCASE(&COMPARE_BY_HIGH_INFLATION) EQ YES %THEN %DO; /**********************************************************************************/ /* G-14-A: Macro variable setup. There are 31 macro variables used by this macro. */ /* The following macro variable is defined in the ME Home Market Program: */ /* * COST_PRIME */ /* The following 9 macro variables are defined in the ME Home Market */ /* Program and ME Margin Calculation Program: */ /* * COMPARE_BY_HIGH_INFLATION */ /* * COST_CHAR */ /* * COST_MANUF */ /* * COST_MATCH */ /* * COST_QTY */ /* * COST_TIME_PERIOD */ /* * COST_YEAR_MONTH */ /* * LAST_YEAR_MONTH */ /* * PRINTOBS */ /* The following macro variables is defined in the G10_TIME_PROD_LIST, */ /* HM1_PRIME_MANUF_MACROS, and US1_MACROS macros: */ /* * COST_PRIM */ /* * COST_MANF */ /* The following 2 macro variables are defined in the */ /* HM1_PRIME_MANUF_MACROS and US1_MACROS macros: */ /* * NO_PROD_COST_MANF */ /* * NO_PROD_COST_PRIME */ /* The following 8 macro variables are defined in the */ /* G8_FIND_NOPRODUCTION macro and also the G14_HIGH_INFLATION macro: */ /* * COST_MFR_HP */ /* * COST_MFR_HP_RENAME */ /* * COST_MFR_HP_RENAME_BACK */ /* * COST_MFR_HP_SAME */ /* * COST_PRIME_HP */ /* * COST_PRIME_HP_RENAME */ /* * COST_PRIME_HP_RENAME_BACK */ /* * COST_PRIME_HP_SAME */ /* The following 2 macro variables are defined in the */ /* G10_TIME_PROD_LIST and G14_HIGH_INFLATION: */ /* * DIF_CHAR (Defined using PROC SQL) */ /* * NOPROD_CHAR (Defined using PROC SQL) */ /* The following 7 macro variables are defined within and exclusively */ /* used by the G14_HIGH_INFLATION macro: */ /* * AND_COST_MANF */ /* * SURROGATE_COST_MFR_LABEL */ /* * SURROGATE_COST_PRIME_LABEL */ /* * NO_PROD_COST_MANF_LABEL */ /* * NO_PROD_COST_PRIME_LABEL */ /* * RENAME_NOPROD_CHAR (Defined using PROC SQL) */ /* * RENAME_NOPROD_CHAR_BACK (Defined using PROC SQL) */ /**********************************************************************************/ /*-----------------------------------------------------------------------*/ /* G-14: Define macro variables and set their default values to nothing. */ /*-----------------------------------------------------------------------*/ /* 15 macro variables */ %GLOBAL AND_COST_MANF COST_MFR_HP COST_MFR_HP_RENAME COST_MFR_HP_RENAME_BACK COST_MFR_HP_SAME COST_PRIME_HP COST_PRIME_HP_RENAME COST_PRIME_HP_RENAME_BACK COST_PRIME_HP_SAME NO_PROD_COST_MANF_LABEL NO_PROD_COST_PRIME_LABEL RENAME_NOPROD_CHAR RENAME_NOPROD_CHAR_BACK SURROGATE_COST_MFR_LABEL SURROGATE_COST_PRIME_LABEL; /*---------------------------------------------------------------------------*/ /* Assign null macro variable values when Cost manufacturer is not relevant. */ /*---------------------------------------------------------------------------*/ %LET AND_COST_MANF = ; /* AND operator for Cost manufacturer purposes */ %LET SURROGATE_COST_MFR_LABEL = ; /* Surrogate Cost manufacturer variable label */ %LET SURROGATE_COST_PRIME_LABEL = ; /* Surrogate Cost prime variable label */ %LET NO_PROD_COST_MANF_LABEL = ; /* No production Cost manufacturer variable label */ %LET NO_PROD_COST_PRIME_LABEL = ; /* No production Cost manufacturer variable label */ /*------------------------------------------------------------*/ /* Assign null macro variable values when HM sales */ /* manufacturer or Cost manufacturer is not relevant. */ /*------------------------------------------------------------*/ %LET COST_MFR_HP = ; /* Cost manufacturer variable */ %LET COST_MFR_HP_RENAME = ; /* Rename cost mfr variable to no-prod cost mfr variable */ %LET COST_MFR_HP_RENAME_BACK = ; /* Rename no-prod cost mfr variable to cost mfr variable */ %LET COST_MFR_HP_SAME = ; /* If no-prod cost mfr variable equal cost mfr variable */ /*-----------------------------------------------------------------*/ /* Assign null macro variable values when HM sales Prime/Non-prime */ /* or Cost Prime/Non-prime are not relevant. */ /*-----------------------------------------------------------------*/ %LET COST_PRIME_HP = ; /* Cost prime variable */ %LET COST_PRIME_HP_RENAME = ; /* Rename Cost prime variable to no-prod cost prime variable */ %LET COST_PRIME_HP_RENAME_BACK = ; /* Rename no-prod prime mfr variable to cost prime variable */ %LET COST_PRIME_HP_SAME = ; /* If no-prod prime variable to cost prime variable */ /*---------------------------------------------------------*/ /* Assign macro variable values when HM sales manufacturer */ /* and Cost manufacturer are relevant. */ /*---------------------------------------------------------*/ %IF %UPCASE(&HMMANUF) NE NA AND %UPCASE(&COST_MANUF) NE NA %THEN /* When there is reported HM and Cost mfr */ %DO; %LET COST_MFR_HP = &COST_MANUF; %LET COST_MFR_HP_RENAME = &COST_MANUF = NO_PROD_MFR; %LET COST_MFR_HP_RENAME_BACK = NO_PROD_MFR = &COST_MANUF; %LET COST_MFR_HP_SAME = &COST_MANUF = NO_PROD_MFR; %END; /*-------------------------------------------------------*/ /* Assign macro variables values when HM Prime/Non-prime */ /* and Cost Prime/Non-prime are relevant. */ /*-------------------------------------------------------*/ %IF %UPCASE(&HMPRIME) NE NA AND %UPCASE(&COST_PRIME) NE NA %THEN /* When there is reported HM and Cost prime */ %DO; %LET COST_PRIME_HP = &COST_PRIME; %LET COST_PRIME_HP_RENAME = &COST_PRIME = NO_PROD_PRIME; %LET COST_PRIME_HP_RENAME_BACK = NO_PROD_PRIME = &COST_PRIME_HP; %LET COST_PRIME_HP_SAME = &COST_PRIME = NO_PROD_PRIME; %END; /*-------------------------------------------------------*/ /* Assign macro variables values when Cost manufacturer */ /* is relevant. */ /*-------------------------------------------------------*/ %IF %UPCASE(&COST_MANUF) NE NA %THEN /* When there is reported Cost manufacturer */ %DO; %LET AND_COST_MANF = AND ; %LET NO_PROD_COST_MANF_LABEL = &NO_PROD_COST_MANF = 'NO PROCUCTION*MANUFACTURER'; %IF %UPCASE(&COMPARE_BY_HIGH_INFLATION) EQ YES %THEN %DO; %LET SURROGATE_COST_MFR_LABEL = &COST_MFR_HP = 'SURROGATE*MANUFACTURER'; %END; %END; /*---------------------------------------------------------*/ /* Assign macro variables values when Cost Prime/Non-prime */ /* is relevant. */ /*---------------------------------------------------------*/ %IF %UPCASE(&COST_PRIME) NE NA %THEN /* When there is reported Cost prime */ %DO; %LET NO_PROD_COST_PRIME_LABEL = &NO_PROD_COST_PRIME = 'NO PROCUCTION*PRIME'; %IF %UPCASE(&COMPARE_BY_HIGH_INFLATION) EQ YES %THEN %DO; %LET SURROGATE_COST_PRIME_LABEL = &COST_PRIME = "SURROGATE*PRIME"; %END; %END; /*-----------------------------------------------------------------------*/ /* Print a sample of Cost calculations before high inflation adjustmets. */ /*-----------------------------------------------------------------------*/ PROC PRINT DATA = COST (OBS = &PRINTOBS); TITLE3 "SAMPLE OF COST CALCULATIONS BEFORE HIGH INFLATION ADJUSTMENTS"; RUN; /***************************************************************************************/ /* G-14-A: Find costs for CONNUMs/Months sold and produced in the same CONNUMs/Months. */ /***************************************************************************************/ /********************************************************/ /* G-14-A-i: Find extended costs using monthly indexes. */ /********************************************************/ DATA REPORTED_EXTENDED_COST (DROP = I); SET COST; LENGTH FIRST_YEAR_MONTH LAST_YEAR_MONTH $6.; FIRST_YEAR_MONTH = CAT(PUT(YEAR("&BEGINPERIOD"D), 4.), PUT(MONTH("&BEGINPERIOD"D), Z2.)); LAST_YEAR_MONTH = CAT(PUT(YEAR("&ENDPERIOD"D), 4.), PUT(MONTH("&ENDPERIOD"D), Z2.)); ENDINDEX = INPUT(PUT("&LAST_YEAR_MONTH", $PRICE_INDEX.), 8.); INDEX = INPUT(PUT(&COST_YEAR_MONTH, $PRICE_INDEX.), 8.); INFLATOR = ENDINDEX / INDEX; ARRAY EXTEND (*) TCOMCOP VCOMCOP GNACOP INTEXCOP TOTALCOP; ARRAY EXTENDED (*) TCOMCOP_EXT VCOMCOP_EXT GNACOP_EXT INTEXCOP_EXT TOTALCOP_EXT; DO I = 1 TO DIM(EXTEND); EXTENDED(I) = EXTEND(I) * INFLATOR; END; RUN; PROC PRINT DATA = REPORTED_EXTENDED_COST (OBS = &PRINTOBS) SPLIT = '<'; VAR &COST_MFR_HP &COST_PRIME_HP &COST_MATCH &COST_YEAR_MONTH TCOMCOP VCOMCOP GNACOP INTEXCOP TOTALCOP INDEX ENDINDEX INFLATOR TCOMCOP_EXT VCOMCOP_EXT GNACOP_EXT INTEXCOP_EXT TOTALCOP_EXT; LABEL &COST_YEAR_MONTH = 'YEAR AND 0.8, B) Test & Base obs >= 2, C) Base qty >= 5%"; RUN; /****************************************************************/ /* US-13-D-ii-f. Merge results into U.S. sales data. Sales are */ /* flagged as either passing or not passing. */ /****************************************************************/ PROC SORT DATA = DPSALES OUT = DPSALES; BY &DP_GROUP &USMANF &USPRIM USLOT &USCONNUM; RUN; DATA DPSALES DPSALES_PASS_&DP_GROUP; MERGE DPSALES (IN=A) &DP_GROUP._RESULTS (IN=B KEEP=&DP_GROUP &USMANF &USPRIM USLOT &USCONNUM &DP_GROUP._RESULT); BY &DP_GROUP &USMANF &USPRIM USLOT &USCONNUM; IF A AND B THEN DO; OUTPUT DPSALES; IF &DP_GROUP._RESULT = "Pass" THEN OUTPUT DPSALES_PASS_&DP_GROUP; END; IF A AND NOT B THEN DO; &DP_GROUP._RESULT = "No Pass"; OUTPUT DPSALES; END; RUN; %MEND COHENS_D; /********************************************************************************/ /* US-13-D-iii. Execute Stage 1: Cohens-d Test for region, time, then purchaser */ /********************************************************************************/ %COHENS_D(DP_REGION,FIRST PASS: ANALYSIS BY REGION) %COHENS_D(DP_PERIOD,SECOND PASS: ANALYSIS BY TIME PERIOD) %COHENS_D(DP_PURCHASER,THIRD AND FINAL PASS: ANALYSIS BY PURCHASER) /*************************************************************************/ /* US-13-E. Stage 2: Calculate Ratios of Sales Passing the Cohens-d Test */ /*************************************************************************/ /**********************************************************************/ /* US-13-E-i. Sales that pass any of the three rounds of the Cohens-d */ /* analysis pass the test as a whole. */ /**********************************************************************/ DATA DPSALES DPPASS (KEEP=DP_COUNT COHENS_D_PASS); SET DPSALES; FORMAT COHENS_D_PASS $3.; COHENS_D_PASS = "No"; IF DP_PURCHASER_RESULT = "Pass" OR DP_REGION_RESULT = "Pass" OR DP_PERIOD_RESULT = "Pass" THEN COHENS_D_PASS = "Yes"; RUN; PROC SORT DATA = DPSALES OUT = DPSALES; BY &USMANF &USPRIM USLOT &USCONNUM DP_PERIOD DP_REGION DP_PURCHASER; RUN; DATA DPSALES_PRINT; SET DPSALES; BY &USMANF &USPRIM USLOT &USCONNUM DP_PERIOD DP_REGION DP_PURCHASER; IF FIRST.&USCONNUM OR FIRST.DP_PERIOD OR FIRST.DP_REGION OR FIRST.DP_PURCHASER THEN OUTPUT DPSALES_PRINT; RUN; PROC SORT DATA = DPSALES_PRINT OUT = DPSALES_PRINT; BY COHENS_D_PASS &USMANF &USPRIM USLOT &USCONNUM; RUN; DATA DPSALES_PRINT (DROP=COUNT); SET DPSALES_PRINT; BY COHENS_D_PASS &USMANF &USPRIM USLOT &USCONNUM; IF FIRST.COHENS_D_PASS THEN COUNT = 1; COUNT + 1; IF COUNT LE &PRINTOBS THEN OUTPUT; RUN; PROC PRINT DATA = DPSALES_PRINT; ID COHENS_D_PASS; BY COHENS_D_PASS; VAR &USMANF &USPRIM USLOT &USCONNUM DP_PERIOD DP_REGION DP_PURCHASER DP_PERIOD_RESULT DP_REGION_RESULT DP_PURCHASER_RESULT; TITLE4 "SAMPLE OF &PRINTOBS FOR EACH TYPE OF RESULT FROM THE COHEN'S-D ANALYSIS FOR"; TITLE5 "UNIQUE COMBINATIONS OF REGION, PURCHASER AND TIME PERIOD FOR EACH CONTROL NUMBER"; RUN; /******************************************************************************/ /* US-13-E-iii. Calculate the percentage of sales that pass the Cohens-d Test */ /******************************************************************************/ PROC MEANS DATA = DPSALES NOPRINT; VAR DP_NETPRI; WEIGHT &USQTY; OUTPUT OUT = OVERALL (DROP = _:) SUM = TOTAL_VALUE; RUN; PROC MEANS DATA = DPSALES NOPRINT; WHERE COHENS_D_PASS = "Yes"; VAR DP_NETPRI; WEIGHT &USQTY; OUTPUT OUT = PASS (DROP = _:) SUM = PASS_VALUE; RUN; DATA OVERALL_DPRESULTS; MERGE OVERALL (IN = A) PASS (IN = B); IF NOT B THEN PASS_VALUE = 0; PERCENT_VALUE_PASSING = PASS_VALUE / TOTAL_VALUE; %GLOBAL PERCENT_VALUE_PASSING; CALL SYMPUT("PERCENT_VALUE_PASSING", PUT(PERCENT_VALUE_PASSING, &PERCENT_FORMAT.)); LENGTH CALC_METHOD $11.; IF PERCENT_VALUE_PASSING = 0 THEN CALC_METHOD = 'STANDARD'; ELSE DO; IF PERCENT_VALUE_PASSING EQ 1 THEN CALC_METHOD = 'ALTERNATIVE'; ELSE CALC_METHOD = 'MIXED'; END; %GLOBAL CALC_METHOD; CALL SYMPUT("CALC_METHOD", CALC_METHOD); RUN; PROC PRINT DATA = OVERALL_DPRESULTS SPLIT = "*" NOOBS; VAR PASS_VALUE TOTAL_VALUE PERCENT_VALUE_PASSING; FORMAT PASS_VALUE TOTAL_VALUE &COMMA_FORMAT. PERCENT_VALUE_PASSING &PERCENT_FORMAT.; LABEL PASS_VALUE = "VALUE OF*PASSING SALES*=============" TOTAL_VALUE = "VALUE OF*ALL SALES*=========" PERCENT_VALUE_PASSING = "PERCENT OF*SALES PASSING*BY VALUE*============="; TITLE4 "OVERALL RESULTS"; TITLE10 "CASE ANALYST: Please notify management of results re: the selection of correct method to be used."; FOOTNOTE1 "If some sales pass the Cohens-d Test and others do not pass, then three methods will be calculated:"; FOOTNOTE2 "1) the Standard Method (applied to all sales), 2) the A-to-T Alternative Method (applied to all sales)"; FOOTNOTE3 "3) and the Mixed Alternative Method which will be a combination of the A-to-A (with offsets)"; FOOTNOTE4 "applied to sales that did not pass, and A-to-T (without offsets) applied to sales that did pass."; FOOTNOTE6 "If either no sale or all sales pass the Cohens-d Test, then the Mixed Alternative Method will yield the same"; FOOTNOTE7 "results as the Standard Method or the A-to-T Alternative Method, respectively, and will not be calculated."; FOOTNOTE9 "*** BUSINESS PROPRIETARY INFORMATION SUBJECT TO APO ***"; FOOTNOTE10 "&BDAY, &BWDATE - &BTIME"; RUN; FOOTNOTE1 "*** BUSINESS PROPRIETARY INFORMATION SUBJECT TO APO ***"; FOOTNOTE2 "&BDAY, &BWDATE - &BTIME"; %GLOBAL ABOVE_DEMINIMIS_STND ABOVE_DEMINIMIS_ALT ABOVE_DEMINIMIS_MIXED CASH_DEPOSIT_DONE; %LET ABOVE_DEMINIMIS_STND = NO;/* Default value. Do not edit. */ %LET ABOVE_DEMINIMIS_ALT = NO; /* Default value. Do not edit. */ %LET ABOVE_DEMINIMIS_MIXED = NO;/* Default value. Do not edit. */ %LET CASH_DEPOSIT_DONE = NO; /* Default value. Do not edit. */ %MEND US13_COHENS_D_TEST; /********************************************************************/ /* US-14: WEIGHT AVERAGING OF U.S. SALES DATA */ /********************************************************************/ %MACRO US14_WT_AVG_DATA; /*------------------------------------------------------------*/ /* 14-A Create macro variables to keep required variables and */ /* determine the weight averaging pools for U.S. sales. */ /* */ /* The macro variables AR_VARS and AR_BY_VARS will contain */ /* lists of additional variables needed for weight-averaging */ /* and assessment purposes in administrative reviews. */ /* */ /* For administrative reviews, the weight-averaging pools */ /* will also be defined by month for cash deposit do */ /* calculations. To this, the macro variable AR_BY_VARS will */ /* be used in the BY statements that will either be set to a */ /* blank value for investigations or the US month variable in */ /* administrative reviews. */ /* */ /* When the Cohens-d Test determines that the Mixed */ /* Alternative Method is to be used, then the DP_COUNT and */ /* COHENS_D_PASS macro variables will be to the variables by */ /* the same names in order to keep track of which */ /* observations passed Cohens-d and which did not. Otherwise, */ /* the DP_COUNT and COHENS_D_PASS macro variables will be set */ /* to null values. In addition, the MIXED_BY_VAR macro */ /* variable will be set to COHENS_D_PASS in order to allow */ /* the weight-averaging to be constricted to within just */ /* sales passing the Cohens-d test. */ /* */ /* When an assessment calculation is warranted, the section */ /* will be re-executed on an importer-specific basis. This */ /* is done by adding the US_IMPORTER variables to the BY */ /* statements. */ /*------------------------------------------------------------*/ %GLOBAL AR_VARS AR_BY_VARS TITLE4_WTAVG TITLE4_MCALC DP_COUNT COHENS_D_PASS ; %IF %UPCASE(&CASE_TYPE) = INV %THEN %DO; %LET AR_VARS = ; %LET AR_BY_VARS = ; /* For weight averaging */ %LET TITLE4_WTAVG = CONTROL NUMBER AVERAGING CALCULATIONS FOR CASH DEPOSIT PURPOSES; /* For results calculations */ %LET TITLE4_MCALC = CALCULATIONS FOR CASH DEPOSIT PURPOSES; %END; %IF %UPCASE(&CASE_TYPE) = AR %THEN %DO; %LET AR_VARS = US_IMPORTER SOURCEU ENTERED_VALUE; %IF &CASH_DEPOSIT_DONE = NO %THEN %DO; %IF %UPCASE(&COMPARE_BY_TIME) EQ NO %THEN /* In quarterly cost reviews do not weight average by USMONTH */ %DO; %LET AR_BY_VARS = &USMON; %END; %IF %UPCASE(&COMPARE_BY_TIME) EQ YES %THEN /* In annualized cost reviews weight average by USMONTH */ %DO; %LET AR_BY_VARS = ; %END; %LET TITLE4_WTAVG = CONTROL NUMBER AVERAGING CALCULATIONS FOR CASH DEPOSIT PURPOSES; %LET TITLE4_MCALC = CALCULATIONS FOR CASH DEPOSIT PURPOSES; %END; %ELSE %IF &CASH_DEPOSIT_DONE = YES %THEN %DO; %IF %UPCASE(&COMPARE_BY_TIME) EQ NO %THEN /* In quarterly cost reviews do not weight average by USMONTH AND IMPORTER */ %DO; %LET AR_BY_VARS = &USMON US_IMPORTER; %END; %ELSE %IF %UPCASE(&COMPARE_BY_TIME) EQ YES %THEN /* In annualized cost reviews weight average by IMPORTER */ %DO; %LET AR_BY_VARS = US_IMPORTER; %END; %LET TITLE4_WTAVG = IMPORTER-SPECIFIC AVERAGING CALCULATIONS FOR ASSESSMENT PURPOSES; %LET TITLE4_MCALC = IMPORTER-SPECIFIC CALCULATIONS FOR ASSESSMENT PURPOSES; %END; %END; %IF &CALC_METHOD NE STANDARD %THEN %DO; %LET DP_COUNT = DP_COUNT; %LET COHENS_D_PASS = COHENS_D_PASS; PROC SORT DATA = USSALES OUT = USSALES; BY DP_COUNT; RUN; PROC SORT DATA = DPPASS OUT = DPPASS; BY DP_COUNT; RUN; DATA USSALES; MERGE USSALES (IN=A) DPPASS (IN=B); BY DP_COUNT; IF A & B; RUN; %END; %ELSE %DO; %LET DP_COUNT = ; %LET COHENS_D_PASS = ; %END; /*---------------------------------------------------------/ /* 14-B Keep variables required for rest of calculations. */ /*--------------------------------------------------------*/ PROC SORT DATA = USSALES (KEEP = &USMANF &USPRIM USLOT &USMON &US_TIME_PERIOD SALE_TYPE &USCONNUM &USCHAR NVMATCH &USQTY &EXRATE1 &EXRATE2 USNETPRI USCOMM USCREDIT USDIRSELL USPACK USECEPOFST CEPOFFSET COMOFFSET INDDOL COMMDOL ICOMMDOL &P2P_VARS &CV_VARS &AR_VARS &DP_COUNT &COHENS_D_PASS) OUT = USNETPR; BY &USMANF &USPRIM USLOT SALE_TYPE &USCONNUM &US_TIME_PERIOD &AR_BY_VARS &COHENS_D_PASS; RUN; /*----------------------------------------------------------*/ /* 14-C Weight-average U.S. prices and adjustments. The */ /* averaged variables for the Standard Method with have */ /* "_MEAN" added to the end of their original names as a */ /* suffix. */ /* */ /* When the Mixed Alternative Method is employed, an extra */ /* weight-averaging will be done that additionally includes */ /* the COHENS_D_PASS variable in the BY statement. This */ /* will allow sales not passing the Cohens-D Test to be */ /* eight-averaged separately from those that did pass. */ /* Weight-averaged amounts will have "_MIXED" added to the */ /* end of their original names. */ /*----------------------------------------------------------*/ %MACRO WEIGHT_AVERAGE(NAMES, DP_BYVAR); PROC MEANS DATA = USNETPR NOPRINT; BY &USMANF &USPRIM USLOT SALE_TYPE &USCONNUM &US_TIME_PERIOD &AR_BY_VARS &DP_BYVAR; VAR USNETPRI USPACK USCOMM USCREDIT USDIRSELL CEPOFFSET COMOFFSET; WEIGHT &USQTY; OUTPUT OUT = USAVG (DROP = _:) MEAN = &NAMES; RUN; DATA USNETPR; MERGE USNETPR USAVG; BY &USMANF &USPRIM USLOT SALE_TYPE &USCONNUM &US_TIME_PERIOD &AR_BY_VARS &DP_BYVAR; RUN; %MEND WEIGHT_AVERAGE; %LET TITLE5 =; %LET TITLE6 =; /*-----------------------------------------------------------*/ /* 14-c-i Execute WEIGHT_AVERAGE macro for Cash Deposit Rate */ /*-----------------------------------------------------------*/ %LET TITLE5 = "AVERAGED VARIABLES ENDING IN '_MEAN' TO BE USED WITH THE STANDARD METHOD"; %LET TITLE6 =; %IF &CASH_DEPOSIT_DONE = NO %THEN %DO; %WEIGHT_AVERAGE(/AUTONAME, ) %IF &CALC_METHOD = MIXED %THEN %DO; %LET TITLE6 = "THOSE ENDING IN '_MIXED' WITH SALES NOT PASSING COHENS'D WITH THE MIXED ALTERNATIVE METHOD."; %WEIGHT_AVERAGE(USNETPRI_MIXED USPACK_MIXED USCOMM_MIXED USCREDIT_MIXED USDIRSELL_MIXED CEPOFFSET_MIXED COMOFFSET_MIXED, COHENS_D_PASS) %END; %END; /*------------------------------------------------------*/ /* 14-c-ii Execute WEIGHT_AVERAGE macro for Assessment */ /*------------------------------------------------------*/ %IF &CASH_DEPOSIT_DONE = YES %THEN %DO; /*----------------------------------------------------------*/ /* 14-c-ii-A Weight-average variables for assessments */ /* using the Standard Method only if the Standard-*/ /* Method Cash Deposit rate is above de minimis. */ /*----------------------------------------------------------*/ %IF &ABOVE_DEMINIMIS_STND = YES %THEN %DO; %LET TITLE6 = "THOSE ENDING IN '_MEAN' WITH SALES NOT PASSING COHENS'D WITH THE STANDARD METHOD."; %WEIGHT_AVERAGE(/AUTONAME, ) %END; /*----------------------------------------------------------*/ /* 14-c-ii-B Weight-average variables for assessments using */ /* the Mixed Alternative Method, if required. */ /*----------------------------------------------------------*/ %IF &ABOVE_DEMINIMIS_MIXED = YES %THEN %DO; %LET TITLE6 = "THOSE ENDING IN '_MIXED' WITH SALES NOT PASSING COHENS'D WITH THE MIXED ALTERNATIVE METHOD."; %WEIGHT_AVERAGE(USNETPRI_MIXED USPACK_MIXED USCOMM_MIXED USCREDIT_MIXED USDIRSELL_MIXED CEPOFFSET_MIXED COMOFFSET_MIXED, COHENS_D_PASS) %END; /*-------------------------------------------------------*/ /* 14-c-ii-C Weight-average variables for assessments */ /* using the Alternative Method, if required. */ /*-------------------------------------------------------*/ %IF &ABOVE_DEMINIMIS_ALT = YES %THEN %DO; %LET TITLE6 = ""; %END; %END; %MEND US14_WT_AVG_DATA; /**************************************************************************/ /* US-15: FUPDOL, NORMAL VALUE AND COMPARISON RESULTS */ /* */ /* For variables with the macro variable SUFFIX added to their names, */ /* weight-averaged values will be used when SUFFIX = _MEAN or _MIXED, */ /* but single-transaction values will be used when the suffix is a */ /* blank space. For example, USNETPRI will be used in calculating the */ /* Alternative Method, USNETPRI_MEAN for the Standard Method */ /* and USNETPRI_MIXED with the sales not passing Cohens-D for the */ /* Mixed Alternative Method. */ /* */ /* For purposes of calculating the initial cash deposit rate, the */ /* IMPORTER macro variable will be set to a blank space and not enter */ /* into the calculations. When an assessment calculation is warranted, */ /* the section will be re-executed on an importer-specific basis by */ /* setting the IMPORTER macro variable to US_IMPORTER. */ /**************************************************************************/ %MACRO US15_RESULTS; %MACRO CALC_RESULTS(METHOD,CALC_TYPE,IMPORTER,OUTDATA,SUFFIX); /*--------------------------------------------------------------*/ /* 15-A. Set up macros for this section. */ /*--------------------------------------------------------------*/ %IF &METHOD=STANDARD %THEN %DO; %LET AVG_TITLE = AVERAGE-TO-AVERAGE; %LET OFFSET_TITLE = BEFORE OFFSETTING (SHOULD IT BE REQUIRED); %MACRO TOTDUMP_LABEL; TOTDUMPING = 'TOTAL AMOUNT*OF DUMPING *(D=B+C IF >0)*============='; %MEND TOTDUMP_LABEL; %IF &CALC_TYPE = STANDARD %THEN %DO; %LET TITLE5 = "STANDARD METHOD APPLIED TO ALL SALES USING VALUES ENDING WITH SUFFIX '_MEAN'"; %MACRO IF_COHEN; %MEND IF_COHEN; %END; %IF &CALC_TYPE = MIXED %THEN %DO; %LET TITLE5 = "MIXED ALTERNATIVE METHOD PART 1: A-to-A APPLIED TO SALES NOT PASSING COHENS-D USING VALUES ENDING WITH SUFFIX '_MIXED'"; %MACRO IF_COHEN; IF COHENS_D_PASS = "No"; %MEND IF_COHEN; %END; %END; %IF &METHOD=ALTERNATIVE %THEN %DO; %LET AVG_TITLE = AVERAGE-TO-TRANSACTION; %LET OFFSET_TITLE = ; %MACRO TOTDUMP_LABEL; TOTDUMPING = 'TOTAL AMOUNT*OF DUMPING *( D=B )*============='; %MEND TOTDUMP_LABEL; %IF &CALC_TYPE = ALTERNATIVE %THEN %DO; %LET TITLE5 = "ALTERNATIVE METHOD APPLIED TO ALL U.S. SALES"; %MACRO IF_COHEN; %MEND IF_COHEN; %END; %IF &CALC_TYPE = MIXED %THEN %DO; %LET TITLE5 = "MIXED ALTERNATIVE METHOD PART 2: A-to-T APPLIED TO SALES PASSING COHENS-D TEST"; %MACRO IF_COHEN; IF COHENS_D_PASS = "Yes"; %MEND IF_COHEN; %END; %END; /*--------------------------------------------------------------*/ /* 15-B. Calculate Results */ /*--------------------------------------------------------------*/ DATA COMPANY.&RESPONDENT._&SEGMENT._&STAGE._&OUTDATA NONVMARG_&OUTDATA; SET USNETPR; %IF_COHEN %MACRO FUPDOL; %IF &CALC_P2P = YES %THEN %DO; %IF &CALC_CV = YES %THEN %DO; IF NVMATCH = 3 THEN %FUPDOL_CV ELSE %FUPDOL_P2P %END; %IF &CALC_CV = NO %THEN %DO; %FUPDOL_P2P %END; %END; %ELSE %IF &CALC_P2P = NO %THEN %DO; %IF &CALC_CV = YES %THEN %DO; %FUPDOL_CV %END; %END; %MEND FUPDOL; %FUPDOL IF SALE_TYPE = 'EP' THEN NV = FUPDOL - COMOFFSET&SUFFIX + USCOMM&SUFFIX + USDIRSELL&SUFFIX + USCREDIT&SUFFIX; ELSE NV = FUPDOL - COMOFFSET&SUFFIX + USCOMM&SUFFIX + USDIRSELL&SUFFIX - CEPOFFSET&SUFFIX; UMARGIN = NV - USNETPRI&SUFFIX; EMARGIN = UMARGIN * &USQTY; USVALUE = USNETPRI&SUFFIX * &USQTY; PCTMARG = UMARGIN / USNETPRI&SUFFIX * 100; IF UMARGIN = . OR NV = . OR USNETPRI&SUFFIX = . THEN OUTPUT NONVMARG_&OUTDATA; ELSE OUTPUT COMPANY.&RESPONDENT._&SEGMENT._&STAGE._&OUTDATA; RUN; PROC PRINT DATA = NONVMARG_&OUTDATA (OBS=&PRINTOBS); TITLE3 "SAMPLE OF U.S. SALES TRANSACTIONS WITH MISSING COMPARISON RESULTS"; TITLE4 "&TITLE4_MCALC"; TITLE5 &TITLE5; RUN; PROC SORT DATA = COMPANY.&RESPONDENT._&SEGMENT._&STAGE._&OUTDATA OUT = COMPANY.&RESPONDENT._&SEGMENT._&STAGE._&OUTDATA; BY DESCENDING PCTMARG; RUN; PROC PRINT DATA = COMPANY.&RESPONDENT._&SEGMENT._&STAGE._&OUTDATA (OBS = &PRINTOBS) SPLIT = "*"; TITLE3 "SAMPLE OF &AVG_TITLE COMPARISON RESULT CALCULATIONS &OFFSET_TITLE"; LABEL UMARGIN = "PER-UNIT*COMPARISON*RESULTS*(UMARGIN)" EMARGIN = "TRANSACTION*COMPARISON*RESULTS*(EMARGIN)" PCTMARG = "COMPARISON*RESULT AS*PCT OF VALUE*(PCTMARG)"; TITLE4 "&TITLE4_MCALC (SORTED BY DESCENDING PCTMARG)"; TITLE5 &TITLE5; RUN; /*------------------------------------------------------------*/ /* 15-C. Keep variables needed for remaining calculations and */ /* put them in the database SUMMARG_. The */ /* SUMMARG_ dataset does not contain any */ /* offsetting information. will be as follows */ /* */ /* AVGMARG: Cash Deposit, Standard Method */ /* AVGMIXED: Cash Deposit, sales not passing Cohens-d for */ /* Mixed Alternative Method */ /* TRNMIXED: Cash Deposit, sales passing Cohens-d for */ /* Mixed Alternative Method */ /* TRANMARG: Cash Deposit, A-to-T Alternative Method */ /* */ /* IMPSTND: Assessment, Standard Method */ /* IMPCSTN: Assessment, sales not passing Cohens-d for */ /* Mixed Alternative Method */ /* IMPCTRN: Assessment, sales passing Cohens-d for Mixed */ /* Alternative Method */ /* IMPTRAN: Assessment, A-to-T Alternative Method */ /*------------------------------------------------------------*/ PROC SORT DATA = COMPANY.&RESPONDENT._&SEGMENT._&STAGE._&OUTDATA OUT = SUMMARG_&OUTDATA (KEEP = &IMPORTER &USQTY USNETPRI&SUFFIX USVALUE PCTMARG EMARGIN UMARGIN &USMANF SALE_TYPE NVMATCH USECEPOFST CEPOFFSET COMOFFSET &AR_VARS &COHENS_D_PASS); BY &IMPORTER SALE_TYPE NVMATCH DESCENDING PCTMARG; RUN; %MEND CALC_RESULTS; /*----------------------------------------------------------*/ /* 15-D. Execute the CALC_RESULTS macro for the appropriate */ /* scenario(s). */ /*----------------------------------------------------------*/ /*---------------------------------------------------------------*/ /* 15-D-i. Cash deposit calculations. */ /* */ /* In all cases, the CALC_RESULTS macro will be executed using */ /* the Standard Method and the A-to-T Alternative */ /* Method for the Cash Deposit Rate. If there is a */ /* mixture of sales pass and not passing Cohens-D, then the */ /* CALC_RESULTS macro will be executed a third time using the */ /* Mixed Alternative Method. */ /* */ /* The ABOVE_DEMINIMIS_STND, ABOVE_DEMINIMIS_MIXED and */ /* ABOVE_DEMINIMIS_ALT macro variables were set to "NO" by */ /* default above in US13. They remains "NO" through the */ /* calculation of the Cash Deposit rate(s). If a particular */ /* Cash Deposit rate is above de minimis, its attendant macro */ /* variable gets changed to "YES" to allow for its assessment */ /* calculation in reviews in Sect 15-E-ii below. */ /* */ /* If the Mixed Alternative Method is not being */ /* calculated because all sales either did or did not pass the */ /* Cohens-D Test, then ABOVE_DEMINIMIS_MIXED is set to "NA" */ /*---------------------------------------------------------------*/ %IF &CASH_DEPOSIT_DONE = NO %THEN %DO; %LET ASSESS_TITLE = ; %CALC_RESULTS(STANDARD,STANDARD, ,AVGMARG,_MEAN) %CALC_RESULTS(ALTERNATIVE,ALTERNATIVE, ,TRANMARG, ) %IF &CALC_METHOD = MIXED %THEN %DO; %CALC_RESULTS(STANDARD,MIXED, ,AVGMIXED,_MIXED) %CALC_RESULTS(ALTERNATIVE,MIXED, ,TRNMIXED, ) %END; %END; /*---------------------------------------------------------*/ /* 15-D-ii. Assessment Calculations (Reviews Only). */ /* */ /* For each Method for which its Cash Deposit rate is */ /* above de minimis, calculate information for importer- */ /* specific assessment rates. */ /*---------------------------------------------------------*/ %IF %UPCASE(&CASE_TYPE)= AR %THEN %DO; %IF &CASH_DEPOSIT_DONE = YES %THEN %DO; %LET ASSESS_TITLE = "IMPORTER-SPECIFIC CALCULATIONS FOR ASSESSMENT PURPOSES"; %IF &ABOVE_DEMINIMIS_STND = YES %THEN %DO; %CALC_RESULTS(STANDARD,STANDARD,US_IMPORTER,IMPSTND,_MEAN) %END; %IF &ABOVE_DEMINIMIS_MIXED = YES %THEN %DO; %CALC_RESULTS(STANDARD,MIXED,US_IMPORTER,IMPCSTN,_MIXED) %CALC_RESULTS(ALTERNATIVE,MIXED,US_IMPORTER,IMPCTRN, ) %END; %IF &ABOVE_DEMINIMIS_ALT = YES %THEN %DO; %CALC_RESULTS(ALTERNATIVE,ALTERNATIVE,US_IMPORTER,IMPTRAN, ) %END; %END; %END; %MEND US15_RESULTS; /***************************************************************************/ /* US-16: CALCULATE CASH DEPOSIT RATE */ /***************************************************************************/ %MACRO US16_CALC_CASH_DEPOSIT; /*-----------------------------------------------------------------*/ /* 16-A. The Standard Method will employed on all U.S. sales */ /* regardless of the results of the Cohens-D Test. Also, the */ /* A-to-T Alternative Method will also be used on all sales to */ /* calculate a second Cash Deposit rate. */ /* */ /* When there are both sales that pass and do not pass Cohens-D, a */ /* Mixed Alternative Cash Deposit rate (in addition to the rates */ /* based on the Standard and A-to-T Alternative Methods) will be */ /* calculated using a mixture of A-to-A (with offsets) and A-to-T */ /* (without offsets). To calculate the Mixed rate, the A-to-A */ /* Method will be employed on sales not passing the Cohens-d */ /* Test, the A-to-T Method on the rest and then then two results */ /* will be aggregated. */ /*-----------------------------------------------------------------*/ %MACRO CALC_CASH_DEPOSIT(TEMPDATA, SUFFIX, METHOD); PROC MEANS DATA = SUMMARG_&TEMPDATA NOPRINT; VAR USNETPRI&SUFFIX; WEIGHT &USQTY; OUTPUT OUT = ALLVAL_&TEMPDATA (DROP = _:) N = TOTSALES SUM = TOTVAL SUMWGT = TOTQTY; RUN; /*------------------------------------------------------------*/ /* 16-B. CALCULATE THE MINIMUM AND MAXIMUM COMPARISON RESULTS */ /*------------------------------------------------------------*/ PROC MEANS DATA = SUMMARG_&TEMPDATA NOPRINT; VAR PCTMARG; OUTPUT OUT = MINMAX_&TEMPDATA (DROP = _:) MIN = MINMARG MAX = MAXMARG; RUN; /*-------------------------------------------------------*/ /* 16-C. CALCULATE THE TOTAL QUANTITY AND VALUE OF SALES */ /* WITH POSITIVE COMPARISON RESULTS AND AMOUNT OF */ /* POSITIVE DUMPING */ /*-------------------------------------------------------*/ PROC MEANS DATA = SUMMARG_&TEMPDATA NOPRINT; WHERE EMARGIN GT 0; VAR &USQTY USVALUE EMARGIN; OUTPUT OUT = SUMMAR_&TEMPDATA (DROP = _:) SUM = MARGQTY MARGVAL POSDUMPING; RUN; /*-----------------------------------------------------------------*/ /* 16-D. CALCULATE THE TOTAL AMOUNT OF NEGATIVE COMPARISON RESULTS */ /*-----------------------------------------------------------------*/ PROC MEANS DATA = SUMMARG_&TEMPDATA NOPRINT; WHERE EMARGIN LT 0; VAR EMARGIN; OUTPUT OUT = NEGMARG_&TEMPDATA (DROP = _:) SUM = NEGDUMPING; RUN; /*------------------------------------------------*/ /* 16-E. CALCULATE THE OVERALL MARGIN PERCENTAGES */ /*------------------------------------------------*/ DATA ANSWER_&TEMPDATA; LENGTH CALC_TYPE $11.; MERGE ALLVAL_&TEMPDATA SUMMAR_&TEMPDATA MINMAX_&TEMPDATA NEGMARG_&TEMPDATA; %IF &TEMPDATA = TRNMIXED %THEN %DO; CALC_TYPE = "A-to-T"; %END; %ELSE %IF &TEMPDATA = AVGMIXED %THEN %DO; CALC_TYPE = "A-to-A"; %END; %ELSE %DO; CALC_TYPE = "&METHOD"; %END; IF MARGQTY = . THEN MARGQTY = 0; IF MARGVAL = . THEN MARGVAL = 0; PCTMARQ = (MARGQTY / TOTQTY) * 100; PCTMARV = (MARGVAL / TOTVAL) * 100; IF POSDUMPING = . THEN POSDUMPING = 0; IF NEGDUMPING = . THEN NEGDUMPING = 0; /*-----------------------------------------------------------*/ /* 16-E-1. If the sum of the positive comparison */ /* results is greater than the absolute value of the sum of */ /* the negative comparison results, then offset the positive */ /* results with the negative to calculate total dumping. */ /* If not, then set total dumping to zero. */ /*-----------------------------------------------------------*/ %IF &METHOD = ALTERNATIVE %THEN %DO; TOTDUMPING = POSDUMPING; %END; %ELSE %DO; IF POSDUMPING GT ABS(NEGDUMPING) THEN TOTDUMPING = POSDUMPING + NEGDUMPING; ELSE TOTDUMPING = 0; %END; RUN; %MEND CALC_CASH_DEPOSIT; /*-------------------------------------------------------------*/ /* 16-F. EXECUTE THE CALC_CASH_DEPOSIT MACRO FOR ALL SCENARIOS */ /*-------------------------------------------------------------*/ %CALC_CASH_DEPOSIT(AVGMARG, _MEAN, STANDARD) %CALC_CASH_DEPOSIT(TRANMARG, , ALTERNATIVE) %IF &CALC_METHOD = MIXED %THEN %DO; %CALC_CASH_DEPOSIT(AVGMIXED, _MIXED, STANDARD) %CALC_CASH_DEPOSIT(TRNMIXED, , ALTERNATIVE) %END; %MACRO MIXED; %IF &CALC_METHOD = MIXED %THEN %DO; DATA MIXED; SET ANSWER_AVGMIXED ANSWER_TRNMIXED; RUN; DATA ANSWER_MIXEDSPLIT; SET ANSWER_AVGMIXED ANSWER_TRNMIXED; PCTMARQ = (MARGQTY / TOTQTY) * 100; PCTMARV = (MARGVAL / TOTVAL) * 100; RUN; PROC MEANS DATA = MIXED NOPRINT; VAR TOTSALES TOTQTY TOTVAL MARGQTY MARGVAL POSDUMPING NEGDUMPING TOTDUMPING; OUTPUT OUT = MIXED_SUM (DROP = _:) SUM = TOTSALES TOTQTY TOTVAL MARGQTY MARGVAL POSDUMPING NEGDUMPING TOTDUMPING; RUN; PROC MEANS DATA = MIXED NOPRINT; VAR MINMARG; OUTPUT OUT = MINMARG (DROP = _:) MIN = MINMARG; RUN; PROC MEANS DATA = MIXED NOPRINT; VAR MAXMARG; OUTPUT OUT = MAXMARG (DROP = _:) MAX = MAXMARG; RUN; DATA MIXED_SUM ANSWER_MIXEDMARG (DROP = CALC_TYPE); LENGTH CALC_TYPE $11.; MERGE MIXED_SUM MINMARG MAXMARG; CALC_TYPE = "MIXED"; PCTMARQ = (MARGQTY / TOTQTY) * 100; PCTMARV = (MARGVAL / TOTVAL) * 100; RUN; DATA MIXED_ALL; SET MIXED MIXED_SUM; RUN; PROC PRINT DATA = MIXED_ALL; TITLE3 "WHEN SOME SALES PASS THE COHENS-D AND OTHERS NOT, CALCULATE THE MIXED ALTERNATIVE METHOD"; TITLE4 "COMBINE RESULTS FROM SALES NOT PASSING THE COHENS-D TEST CALCULATED A-to-A WITH OFFSETS"; TITLE5 "WITH RESULTS FROM SALES PASSING THE COHENS-D TEST CALCULATED A-to-T WITHOUT OFFSETS"; RUN; %END; %MEND MIXED; %MIXED /*-------------------------------------------------------*/ /* 16-G. CREATE MACRO VARIABLES TO TRACK WHEN MARGIN */ /* PERCENTAGES ARE ABOVE DE MINIMIS. IF ANY CASH DEPOSIT */ /* RATE IN AN ADMINISTRATIVE REVIEW IS ABOVE DE MINIMIS, */ /* THE ASSESSMENT MACRO WILL RUN. */ /*-------------------------------------------------------*/ %MACRO DE_MINIMIS(OUTDATA,TYPE,CALC); DATA ANSWER_&OUTDATA; SET ANSWER_&OUTDATA; WTAVGPCT_&TYPE = (TOTDUMPING / TOTVAL) * 100; PER_UNIT_RATE_&TYPE = TOTDUMPING / TOTQTY; IF WTAVGPCT_&TYPE GT &DE_MINIMIS THEN ABOVE_DEMIN_&TYPE = 'YES'; ELSE ABOVE_DEMIN_&TYPE = 'NO'; %IF &TYPE = STND %THEN %DO; CALL SYMPUT('ABOVE_DEMINIMIS_STND',ABOVE_DEMIN_&TYPE); %END; %IF &TYPE = ALT %THEN %DO; CALL SYMPUT('ABOVE_DEMINIMIS_ALT',ABOVE_DEMIN_ALT); %END; %IF &TYPE = MIXED %THEN %DO; CALL SYMPUT('ABOVE_DEMINIMIS_MIXED',ABOVE_DEMIN_&TYPE); %END; RUN; %MEND DE_MINIMIS; %DE_MINIMIS(AVGMARG, STND, YES) %DE_MINIMIS(TRANMARG, ALT, YES) %IF &CALC_METHOD = MIXED %THEN %DO; %DE_MINIMIS(MIXEDMARG, MIXED, YES) %END; %ELSE %DO; %LET ABOVE_DEMINIMIS_MIXED = NA; %END; /*------------------------------------------------------------- */ /* 16-H. PRINT CASH DEPOSIT RATE CALCULATIONS FOR ALL SCENARIOS */ /*--------------------------------------------------------------*/ %MACRO PRINT_CASH_DEPOSIT(OUTDATA, METHOD); %GLOBAL SUMVARS METHODOLOGY TITLE FOOTNOTE1 FOOTNOTE2; %IF &METHOD = STANDARD %THEN %DO; %LET SUMVARS = ; %LET METHODOLOGY = STANDARD; %LET TITLE = "AVERAGE-TO-AVERAGE COMPARISONS, OFFSETTING POSITIVE COMPARISON RESULTS WITH NEGATIVE COMPARISON RESULTS"; %LET FOOTNOTE1 = "IF C IS GREATER THAN THE ABSOLUTE VALUE OF D, THEN THE ANTIDUMPING DUTIES DUE"; %LET FOOTNOTE2 = "ARE THE SUM OF C AND D, OTHERWISE THE ANTIDUMPING DUTIES DUE ARE ZERO."; %MACRO TOTDUMP_LABEL; TOTDUMPING = 'TOTAL AMOUNT*OF DUMPING *(E=C+D IF >0)*============='; %MEND TOTDUMP_LABEL; %END; %IF &METHOD = ALTERNATIVE %THEN %DO; %LET SUMVARS = ; %LET METHODOLOGY = A-to-T ALTERNATIVE; %LET TITLE = "AVERAGE-TO-TRANSACTION COMPARISONS, NO OFFSETTING OF POSITIVE COMPARISON RESULTS"; %LET FOOTNOTE1 = "THE ANTIDUMPING DUTIES DUE ARE THE SUM OF THE POSITIVE RESULTS (C)"; %LET FOOTNOTE2 = ; %MACRO TOTDUMP_LABEL; TOTDUMPING = 'TOTAL AMOUNT*OF DUMPING *( E=C )*============='; %MEND TOTDUMP_LABEL; %END; %IF &METHOD = MIXED %THEN %DO; %LET SUMVARS = SUM TOTSALES TOTVAL TOTQTY POSDUMPING NEGDUMPING TOTDUMPING MARGVAL MARGQTY; %LET METHODOLOGY = MIXED ALTERNATIVE; %LET TITLE = "OFFSETTING POSITIVE COMPARISON RESULTS WITH NEGATIVES ONLY FOR SALES NOT PASSING COHENS-D"; %LET FOOTNOTE1 = "FOR SALES THAT FAIL THE COHEN'S-D TEST, AD DUTIES DUE ARE THE SUM OF C AND D (IF C>|D|) OR ZERO."; %LET FOOTNOTE2 = "FOR SALES THAT PASS COHEN'S-D TEST, AD DUTIES DUE ARE THE SUM OF C."; %MACRO TOTDUMP_LABEL; TOTDUMPING = 'TOTAL AMOUNT *OF DUMPING *(SEE FOOTNOTES) *==============='; %MEND TOTDUMP_LABEL; %END; PROC PRINT DATA = ANSWER_&OUTDATA NOOBS SPLIT='*'; VAR CALC_TYPE TOTSALES TOTVAL TOTQTY POSDUMPING NEGDUMPING TOTDUMPING MINMARG MAXMARG MARGVAL MARGQTY PCTMARV PCTMARQ; &SUMVARS; TITLE3 "BUILD UP TO WEIGHT AVERAGE MARGIN"; TITLE4 "USING THE &METHODOLOGY METHOD"; TITLE5 &TITLE; FOOTNOTE1 &FOOTNOTE1; FOOTNOTE2 &FOOTNOTE2; FOOTNOTE4 "*** BUSINESS PROPRIETARY INFORMATION SUBJECT TO APO ***"; FOOTNOTE5 "&BDAY, &BWDATE - &BTIME"; LABEL CALC_TYPE = 'COMPARISON*TYPE* *==========' TOTSALES = ' *NUMBER OF*U.S. SALES* *==========' TOTVAL = 'TOTAL U.S.*SALES VALUE*(A)*================' TOTQTY = 'TOTAL U.S. *QUANTITY *(B) *==============' POSDUMPING = 'TOTAL POSITIVE*COMPARISON RESULTS*(C)*==================' NEGDUMPING = 'TOTAL NEGATIVE*COMPARISON RESULTS*(D)*==================' MARGVAL = 'VALUE OF SALES*WITH POSITIVE*COMPARISON RESULTS*(F)*==================' MARGQTY = 'QUANTITY OF SALES*WITH POSITIVE*COMPARISON RESULTS*(G) *=================' PCTMARV = 'PERCENT OF SALES*WITH POSITIVE*COMPARISON RESULTS*BY VALUE*(F/A x 100)*==================' PCTMARQ = 'PERCENT OF SALES*WITH POSITIVE*COMPARISON RESULTS*BY QUANTITY*(G/B x 100)*==================' MINMARG = 'MINIMUM *COMPARISON*RESULT *(percent)*==========' MAXMARG = 'MAXIMUM *COMPARISON*RESULT *(percent)*==========' %TOTDUMP_LABEL; FORMAT TOTSALES COMMA9. TOTVAL TOTQTY POSDUMPING NEGDUMPING TOTDUMPING MARGVAL MARGQTY MINMARG MAXMARG COMMA16.2 PCTMARV PCTMARQ 6.2; RUN; %MEND PRINT_CASH_DEPOSIT; /*----------------------------------------------------------*/ /* 16-I. EXECUTE PRINT_CASH_DEPOSIT MACRO FOR ALL SCENARIOS */ /*----------------------------------------------------------*/ %PRINT_CASH_DEPOSIT(AVGMARG, STANDARD) %IF &ABOVE_DEMINIMIS_MIXED NE NA %THEN %DO; %PRINT_CASH_DEPOSIT(MIXEDSPLIT,MIXED) %END; %PRINT_CASH_DEPOSIT(TRANMARG, ALTERNATIVE) /*--------------------------------------------------*/ /* 16-J. PRINT CASH DEPOSIT RATES FOR ALL SCENARIOS */ /*--------------------------------------------------*/ %IF &CALC_METHOD = STANDARD %THEN %DO; %LET FOOTNOTE1 = "Because all sales did not pass Cohens-D Test, the Mixed Alternative Cash Deposit Rate is the same as the Cash"; %LET FOOTNOTE2 = "Deposit Rate for the Standard Method. Accordingly, the Mixed Alternative Method will not be used"; %LET FOOTNOTE3 = "separately in the Meaningful Difference Test nor in the calculation of assessments in Administrative Reviews."; %LET ANSWER_MIXEDMARG = ; /* macro variable for mixed database nulled out */ %END; %IF &CALC_METHOD = MIXED %THEN %DO; %LET FOOTNOTE1 = " "; %LET FOOTNOTE2 = " "; %LET FOOTNOTE3 = " "; %LET ANSWER_MIXEDMARG = ANSWER_MIXEDMARG (KEEP=WTAVGPCT_MIXED PER_UNIT_RATE_MIXED); %END; %IF &CALC_METHOD = ALTERNATIVE %THEN %DO; %LET FOOTNOTE1 = "Because all sales passed the Cohens-D Test, the Mixed Alternative Cash Deposit Rate is the same as the Cash Deposit"; %LET FOOTNOTE2 = "Rate for the A-to-T Alternative Method. Accordingly, the Mixed Alternative Method will not be separately"; %LET FOOTNOTE3 = "used in the Meaningful Difference Test nor in the calculation of assessments in Administrative Reviews."; %LET ANSWER_MIXEDMARG = ; %END; PROC FORMAT; VALUE PCT_MARGIN . = "N/A" OTHER = [COMMA9.2]; VALUE UNIT_MARGIN . = "N/A" OTHER = [DOLLAR10.2]; RUN; DATA ANSWER; MERGE ANSWER_AVGMARG (KEEP = WTAVGPCT_STND PER_UNIT_RATE_STND) &ANSWER_MIXEDMARG ANSWER_TRANMARG (KEEP = WTAVGPCT_ALT PER_UNIT_RATE_ALT); %IF &CALC_METHOD NE MIXED %THEN %DO; WTAVGPCT_MIXED = .; PER_UNIT_RATE_MIXED = .; %END; RUN; PROC PRINT DATA = ANSWER NOOBS SPLIT = '*'; %IF %UPCASE(&PER_UNIT_RATE) = NO %THEN %DO; VAR WTAVGPCT_STND WTAVGPCT_MIXED WTAVGPCT_ALT; LABEL WTAVGPCT_STND = "STANDARD METHOD*AD VALOREM*WEIGHT AVERAGE MARGIN*(E/A x 100)*(percent)* *=================" WTAVGPCT_MIXED = "MIXED ALTERNATIVE*METHOD*AD VALOREM*WEIGHT AVERAGE MARGIN*(percent)* *=================" WTAVGPCT_ALT = "A-to-T ALTERNATIVE*METHOD*AD VALOREM*WEIGHT AVERAGE MARGIN*(E/A x 100)*(percent)* *=================="; FORMAT WTAVGPCT_STND WTAVGPCT_MIXED WTAVGPCT_ALT PCT_MARGIN.; %END; %IF %UPCASE(&PER_UNIT_RATE) = YES %THEN %DO; VAR PER_UNIT_RATE_STND PER_UNIT_RATE_MIXED PER_UNIT_RATE_ALT; LABEL PER_UNIT_RATE_STND = "STANDARD METHOD*PER-UNIT*WEIGHT AVERAGE MARGIN*( E/B )* *=================" PER_UNIT_RATE_MIXED = "MIXED ALTERNATIVE*METHOD*PER-UNIT*WEIGHT AVERAGE MARGIN*(percent)* *=================" PER_UNIT_RATE_ALT = "A-to-T ALTERNATIVE*METHOD*PER-UNIT*WEIGHT AVERAGE MARGIN*(E/A x 100)*(percent)* *=================="; FORMAT PER_UNIT_RATE_STND PER_UNIT_RATE_MIXED PER_UNIT_RATE_ALT UNIT_MARGIN.; %END; TITLE3 "WEIGHT AVERAGE MARGINS"; FOOTNOTE1 &FOOTNOTE1; FOOTNOTE2 &FOOTNOTE2; FOOTNOTE3 &FOOTNOTE3; FOOTNOTE6 "*** BUSINESS PROPRIETARY INFORMATION SUBJECT TO APO ***"; FOOTNOTE7 "&BDAY, &BWDATE - &BTIME"; RUN; FOOTNOTE6 "*** BUSINESS PROPRIETARY INFORMATION SUBJECT TO APO ***"; FOOTNOTE7 "&BDAY, &BWDATE - &BTIME"; %LET CASH_DEPOSIT_DONE = YES; %MEND US16_CALC_CASH_DEPOSIT; /*************************************/ /* US-17: MEANINGFUL DIFFERENCE TEST */ /*************************************/ %MACRO US17_MEANINGFUL_DIFF_TEST; %GLOBAL MA_METHOD AT_METHOD; %LET MA_METHOD = N/A; %LET AT_METHOD = N/A; %IF &CALC_METHOD NE STANDARD %THEN %DO; %IF &CALC_METHOD EQ MIXED %THEN %DO; %LET ADD_SET = MIXEDMARG; DATA MIXEDMARG; SET ANSWER_MIXEDMARG (KEEP = WTAVGPCT_MIXED); LENGTH METHOD $18.; METHOD = "MIXED ALTERNATIVE"; RENAME WTAVGPCT_MIXED = WTAVGPCT; RUN; %END; %ELSE %DO; %LET ADD_SET = ; %END; DATA TRANMARG; SET ANSWER_TRANMARG (KEEP = WTAVGPCT_ALT); LENGTH METHOD $18.; METHOD = "A-to-T ALTERNATIVE"; RENAME WTAVGPCT_ALT = WTAVGPCT; RUN; DATA MEANINGFUL_DIFF_TEST; LENGTH RESULT $ 36 MEANINGFUL_DIFF $ 3; SET &ADD_SET TRANMARG; IF _N_ = 1 THEN SET ANSWER_AVGMARG (KEEP = WTAVGPCT_STND); /* default values for WTAVGPCT_STND and WTAVGPCT_ALT less than de minimis */ MEANINGFUL_DIFF = "NO"; RELATIVE_CHANGE = .; RESULT = "NEITHER MARGIN IS ABOVE DE MINIMIS"; IF WTAVGPCT GE &DE_MINIMIS THEN DO; IF WTAVGPCT_STND LT &DE_MINIMIS THEN DO; RESULT = "MOVES ACROSS DE MINIMIS THRESHOLD"; MEANINGFUL_DIFF = "YES"; END; ELSE DO; RELATIVE_CHANGE = (WTAVGPCT - WTAVGPCT_STND)/WTAVGPCT_STND * 100 ; IF RELATIVE_CHANGE GE 25 THEN DO; MEANINGFUL_DIFF = "YES"; RESULT = "RELATIVE MARGIN CHANGE >= 25%"; END; ELSE DO; MEANINGFUL_DIFF = "NO"; RESULT = "RELATIVE MARGIN CHANGE < 25%"; END; END; END; IF METHOD = "MIXED ALTERNATIVE" THEN CALL SYMPUT('MA_METHOD', MEANINGFUL_DIFF); ELSE IF METHOD = "A-to-T ALTERNATIVE" THEN CALL SYMPUT('AT_METHOD', MEANINGFUL_DIFF); RUN; PROC FORMAT; VALUE RELCHNG . = "N/A" OTHER = [COMMA8.2]; RUN; PROC PRINT DATA = MEANINGFUL_DIFF_TEST NOOBS SPLIT = "*"; VAR METHOD WTAVGPCT WTAVGPCT_STND RELATIVE_CHANGE RESULT MEANINGFUL_DIFF; LABEL WTAVGPCT_STND = "MARGIN RATE*STANDARD METHOD*A-to-A with OFFSETS*( B )" WTAVGPCT = "MARGIN RATE*( A )" RELATIVE_CHANGE = "RELATIVE PCT*MARGIN CHANGE*(A-B)/Bx100" RESULT = "RESULT OF TEST" MEANINGFUL_DIFF = "MEANINGFUL DIFFERENCE*IN THE MARGINS?"; FORMAT WTAVGPCT WTAVGPCT_STND RELATIVE_CHANGE RELCHNG.; TITLE3 "RESULTS OF THE MEANINGFUL DIFFERENCE TEST"; TITLE5 "CASE ANALYST: Please notify management of results so that the proper method can be selected."; TITLE7 "PERCENT OF SALES PASSING THE COHEN'S D TEST = %CMPRES(&PERCENT_VALUE_PASSING)"; FOOTNOTE1 "*** BUSINESS PROPRIETARY INFORMATION SUBJECT TO APO ***"; FOOTNOTE2 "&BDAY, &BWDATE - &BTIME"; RUN; %END; %MEND US17_MEANINGFUL_DIFF_TEST; /******************************************************************/ /* US-18: IMPORTER-SPECIFIC DUTY ASSESSMENT RATES (REVIEWS ONLY) */ /* */ /* Calculate and print importer-specific assessment rates */ /* if the cash deposit rate in an administrative review is */ /* above de minimis. */ /******************************************************************/ %MACRO US18_ASSESSMENT; %IF %UPCASE(&CASE_TYPE) = AR %THEN %DO; /*-------------------------------------------------------*/ /* 18-A For all methods for which no assessments will be */ /* calculated, print an explanation. */ /*-------------------------------------------------------*/ %MACRO NO_ASSESS(TYPE); %IF &ABOVE_DEMINIMIS_STND = NO OR &ABOVE_DEMINIMIS_MIXED = NO OR &ABOVE_DEMINIMIS_ALT = NO %THEN %DO; %IF &&ABOVE_DEMINIMIS_&TYPE = NO %THEN %DO; /*-----------------------------------*/ /* 18-A-i All cash deposit rates are */ /* below de minimis. */ /*-----------------------------------*/ %IF &TYPE = ALT %THEN %DO; DATA NOCALC; SET ANSWER (KEEP = WTAVGPCT_ALT); REASON = "HIGHEST POSSIBLE CASH DEPOSIT RATE IS BELOW 0.5 PERCENT (de minimis)"; RUN; PROC PRINT DATA = NOCALC NOOBS SPLIT = "*"; VAR REASON WTAVGPCT_ALT; LABEL WTAVGPCT_ALT = "A-to-T ALTERNATIVE*METHOD*AD VALOREM*CASH DEPOSIT RATE*(percent)* *================" REASON = " "; TITLE3 "NO ASSESSMENTS WILL BE CALCULATED FOR ANY METHOD SINCE THE HIGHEST POSSIBLE"; TITLE4 "CASH DEPOSIT RATE (FOR THE A-to-T ALTERNATIVE METHOD) IS LESS THAN DE MINIMIS"; FORMAT WTAVGPCT_&TYPE PCT_MARGIN.; RUN; PROC SORT DATA = SUMMARG_AVGMARG OUT = IMPORTER_LIST (KEEP = US_IMPORTER) NODUPKEY; BY US_IMPORTER; RUN; PROC PRINT DATA = IMPORTER_LIST SPLIT = '*'; LABEL US_IMPORTER = "&IMPORTER"; TITLE3 "LIST OF REPORTED IMPORTERS OR CUSTOMERS"; RUN; %END; /*---------------------------------------*/ /* 18-A-ii Standard Cash Deposit rate is */ /* below de minimis. */ /*---------------------------------------*/ %IF &TYPE = STND AND &&ABOVE_DEMINIMIS_ALT NE NO %THEN %DO; DATA NOCALC; SET ANSWER (KEEP = WTAVGPCT_STND); REASON = "CASH DEPOSIT RATE IS BELOW 0.5 PERCENT (de minimis)"; RUN; PROC PRINT DATA = NOCALC NOOBS SPLIT = "*"; VAR REASON WTAVGPCT_STND; LABEL WTAVGPCT_STND = "STANDARD METHOD*AD VALOREM*CASH DEPOSIT RATE*(percent)* *================" REASON = " "; TITLE3 "NO ASSESSMENTS WILL BE CALCULATED FOR THE STANDARD METHOD"; FORMAT WTAVGPCT_&TYPE PCT_MARGIN.; RUN; PROC SORT DATA = SUMMARG_AVGMARG OUT = IMPORTER_LIST (KEEP = US_IMPORTER) NODUPKEY; BY US_IMPORTER; RUN; PROC PRINT DATA = IMPORTER_LIST SPLIT = '*'; LABEL US_IMPORTER = "&IMPORTER"; TITLE3 "LIST OF REPORTED IMPORTERS OR CUSTOMERS"; RUN; %END; /*----------------------------------------------*/ /* 18-A-iii The Cash Deposit rate for the Mixed */ /* Alternative Method is below de */ /* minimis. */ /*----------------------------------------------*/ %IF &TYPE = MIXED AND &CALC_METHOD NE STANDARD %THEN %DO; %IF &&ABOVE_DEMINIMIS_ALT NE NO %THEN %DO; DATA NOCALC; SET ANSWER (KEEP = WTAVGPCT_&TYPE); REASON = "CASH DEPOSIT RATE IS BELOW 0.5 PERCENT (de minimis)"; RUN; PROC PRINT DATA = NOCALC NOOBS SPLIT = "*"; VAR REASON WTAVGPCT_&TYPE; LABEL WTAVGPCT_&TYPE = "MIXED ALTERNATIVE*METHOD*AD VALOREM*CASH DEPOSIT RATE*(percent)* *================" REASON = " "; TITLE3 "NO ASSESSMENTS WILL BE CALCULATED FOR THE MIXED ALTERNATIVE METHOD"; FORMAT WTAVGPCT_&TYPE PCT_MARGIN.; RUN; PROC SORT DATA = SUMMARG_AVGMARG OUT = IMPORTER_LIST (KEEP = US_IMPORTER) NODUPKEY; BY US_IMPORTER; RUN; PROC PRINT DATA = IMPORTER_LIST SPLIT = '*'; LABEL US_IMPORTER = "&IMPORTER"; TITLE3 "LIST OF REPORTED IMPORTERS OR CUSTOMERS"; RUN; %END; %END; %END; %END; /*------------------------------------------------------*/ /* 18-A-iv All sales either pass Cohens-D or do not */ /* pass. The Mixed Alternative Method would be */ /* the same as the A-to-T Alternative Method */ /* when all sales pass, or the Standard Method */ /* when all sales do not pass. Therefore, */ /* no need to calculate Mixed Alternative */ /* assessment rates. */ /*------------------------------------------------------*/ %IF &&ABOVE_DEMINIMIS_&TYPE = NA AND &&ABOVE_DEMINIMIS_ALT NE NO %THEN %DO; DATA NOCALC; REASON = "All sales either do not pass/pass the Cohens-D, Mixed Alternative Method the same as Standard/A-to-T Alternative, respectively."; RUN; %IF &ABOVE_DEMINIMIS_STND = NO %THEN %DO; PROC PRINT DATA = NOCALC NOOBS SPLIT = "*"; VAR REASON; LABEL REASON = " "; TITLE3 "NO SEPARATE ASSESMENT CALCULATIONS WILL BE DONE USING THE MIXED ALTERNATIVE METHOD"; TITLE4 "(ASSESSMENTS WILL BE CALCULATED USING THE A-to-T ALTERNATIVE METHOD ONLY)"; RUN; %END; %ELSE %IF &ABOVE_DEMINIMIS_STND = YES %THEN %DO; PROC PRINT DATA = NOCALC NOOBS SPLIT = "*"; VAR REASON; LABEL REASON = " "; TITLE3 "NO SEPARATE ASSESMENT CALCULATIONS WILL BE DONE USING THE MIXED ALTERNATIVE METHOD"; TITLE4 "(ASSESSMENTS WILL BE CALCULATED USING THE STANDARD AND A-to-T ALTERNATIVE METHODS)"; RUN; %END; PROC SORT DATA = SUMMARG_AVGMARG OUT = IMPORTER_LIST (KEEP = US_IMPORTER) NODUPKEY; BY US_IMPORTER; RUN; PROC PRINT DATA = IMPORTER_LIST SPLIT = '*'; LABEL US_IMPORTER = "&IMPORTER"; TITLE3 "LIST OF REPORTED IMPORTERS OR CUSTOMERS"; RUN; %END; %MEND NO_ASSESS; %NO_ASSESS(STND) %NO_ASSESS(MIXED) %NO_ASSESS(ALT) /*-----------------------------------------------------------*/ /* 18-B FOR ALL METHODS FOR WHICH THE CASH DEPOSIT RATES ARE */ /* ABOVE DE MINIMIS, CALCULATE ASSESSMENTS. */ /*-----------------------------------------------------------*/ %IF &ABOVE_DEMINIMIS_STND = YES OR &ABOVE_DEMINIMIS_MIXED = YES OR &ABOVE_DEMINIMIS_ALT = YES %THEN %DO; %US14_WT_AVG_DATA; /* Re-weight average data by importer. */ %US15_RESULTS; /* Recalculate transaction comparison */ /* results using re-weighted data. */ /*----------------------------------------------------------*/ /* 18-B-i The SUMMARG_ dataset does not contain any */ /* offsetting info. Calculate amounts for offsetting */ /* by importer and store them in the database */ /* SUMMAR_, leaving the database */ /* SUMMARG_ unchanged. */ /*----------------------------------------------------------*/ %MACRO CALC_ASSESS(INDATA, CTYPE, CALC_TYPE); PROC MEANS NWAY DATA = SUMMARG_&INDATA NOPRINT; CLASS US_IMPORTER SOURCEU; VAR ENTERED_VALUE; WEIGHT &USQTY; OUTPUT OUT = ENTVAL_&INDATA (DROP = _:) N = SALES SUMWGT = ITOTQTY SUM = ITENTVAL; RUN; /*------------------------------------------------------*/ /* 18-B-ii Calculate the sum of positive comparison */ /* results. */ /*------------------------------------------------------*/ PROC MEANS NWAY DATA = SUMMARG_&INDATA NOPRINT; CLASS US_IMPORTER SOURCEU; WHERE EMARGIN GT 0; VAR EMARGIN; OUTPUT OUT = POSMARG_IMPORTER_&INDATA (DROP = _:) SUM = IPOSRESULTS; RUN; /*---------------------------------------------------*/ /* 18-B-iii Calculate the sum of negative comparison */ /* results. */ /*---------------------------------------------------*/ PROC MEANS NWAY DATA = SUMMARG_&INDATA NOPRINT; CLASS US_IMPORTER SOURCEU; WHERE EMARGIN LT 0; VAR EMARGIN; OUTPUT OUT = NEGMARG_IMPORTER_&INDATA (DROP = _:) SUM = INEGRESULTS; RUN; /*------------------------------------------------------*/ /* 18-B-iv For each importer, if the sum of the */ /* positive comparison results is greater than */ /* the absolute value of the sum of the */ /* negative comparison results, set the total */ /* comparison results to the to the sum of the */ /* positive and negative comparison */ /* results. Otherwise, set the total comparison */ /* results to zero. Calculate the ad valorem */ /* and per-unit assessment rates, and the */ /* de minimis percent. */ /*------------------------------------------------------*/ DATA ASSESS_&INDATA; LENGTH CALC_TYPE $11; MERGE ENTVAL_&INDATA (IN = A) POSMARG_IMPORTER_&INDATA (IN = B) NEGMARG_IMPORTER_&INDATA (IN = C); BY US_IMPORTER SOURCEU; CALC_TYPE = "&CALC_TYPE"; IF A; IF NOT B THEN IPOSRESULTS = 0; IF NOT C THEN INEGRESULTS = 0; %IF &CTYPE = STND %THEN %DO; IF IPOSRESULTS > ABS(INEGRESULTS) THEN ITOTRESULTS = IPOSRESULTS + INEGRESULTS; ELSE ITOTRESULTS = 0; %END; %ELSE %IF &CTYPE = ALT %THEN %DO; ITOTRESULTS = IPOSRESULTS; %END; RUN; %MEND CALC_ASSESS; /*----------------------------------------------------*/ /* 18-C EXECUTE THE CALC_ACCESS MACRO FOR ALL METHODS */ /*----------------------------------------------------*/ /*------------------------*/ /* 18-C-i STANDARD METHOD */ /*------------------------*/ %IF &ABOVE_DEMINIMIS_STND = YES %THEN %DO; %CALC_ASSESS(IMPSTND, STND, STANDARD) %END; /*----------------------------------*/ /* 18-C-ii MIXED ALTERNATIVE METHOD */ /*----------------------------------*/ %IF &ABOVE_DEMINIMIS_MIXED = YES %THEN %DO; %CALC_ASSESS(IMPCSTN, STND, A-to-A) %CALC_ASSESS(IMPCTRN, ALT, A-to-T) /*------------------------------------------------------*/ /* 18-C-i-a COMBINE RESULTS FROM THE PORTION OF SALES */ /* CALCULATED A-to-A WITH OFFSETS, WITH THOSE */ /* FROM SALES CALCULATED A-to-T WITHOUT */ /* OFFSETS. */ /*------------------------------------------------------*/ DATA ASSESS_MIXED_ALL; SET ASSESS_IMPCSTN ASSESS_IMPCTRN; RUN; PROC MEANS NWAY DATA = ASSESS_MIXED_ALL NOPRINT; CLASS US_IMPORTER SOURCEU; VAR SALES ITOTQTY ITENTVAL IPOSRESULTS INEGRESULTS ITOTRESULTS; OUTPUT OUT = ASSESS_MIXED_SUM (DROP = _:) SUM = SALES ITOTQTY ITENTVAL IPOSRESULTS INEGRESULTS ITOTRESULTS; RUN; DATA ASSESS_MIXED_SUM ASSESS_MIXED (DROP = CALC_TYPE); LENGTH CALC_TYPE $11.; SET ASSESS_MIXED_SUM; CALC_TYPE = "MIXED"; RUN; DATA ASSESS_MIXED_ALL; SET ASSESS_MIXED_ALL ASSESS_MIXED_SUM; RUN; PROC SORT DATA = ASSESS_MIXED_ALL OUT = ASSESS_MIXED_ALL; BY US_IMPORTER SOURCEU CALC_TYPE; RUN; PROC PRINT DATA = ASSESS_MIXED_ALL (OBS = &PRINTOBS); BY US_IMPORTER SOURCEU; ID US_IMPORTER SOURCEU; TITLE3 "FOR THE MIXED ALTERNATIVE METHOD, COMBINE"; TITLE4 "RESULTS FROM SALES NOT PASSING COHENS-D CALCULATED A-to-A WITH OFFSETS"; TITLE5 "WITH RESULTS FROM SALES PASSING COHENS-D CALCULATED A-to-T WITHOUT OFFSETS"; RUN; %END; /*-----------------------------*/ /* 18-C-iii ALTERNATIVE METHOD */ /*-----------------------------*/ %IF &ABOVE_DEMINIMIS_ALT = YES %THEN %DO; %CALC_ASSESS(IMPTRAN, ALT, ALTERNATIVE) %END; %END; %MACRO PRINT_ASSESS(INDATA); DATA ASSESS_&INDATA; SET ASSESS_&INDATA; /* AD VALOREM RATE FOR ASSESSMENT */ ASESRATE = (ITOTRESULTS / ITENTVAL)* 100; /* PER-UNIT RATE FOR ASSESSMENT */ PERUNIT = (ITOTRESULTS / ITOTQTY); /* RATE FOR DE MINIMIS TEST. */ DMINPCT = ASESRATE; LENGTH DMINTEST $3. ; IF DMINPCT GE 0.5 THEN DO; DMINTEST = 'NO'; %IF %UPCASE(&PER_UNIT_RATE) = NO %THEN %DO; IF SOURCEU = 'REPORTED' THEN PERUNIT = .; ELSE IF SOURCEU IN ('MIXED','COMPUTED') THEN %END; ASESRATE = .; END; ELSE IF DMINPCT LT 0.5 THEN DO; DMINTEST = 'YES'; ASESRATE = 0; PERUNIT = 0; END; DMINPCT = INT(DMINPCT * 100) / 100; RUN; PROC PRINT DATA = ASSESS_&INDATA SPLIT = '*' WIDTH = MINIMUM; VAR US_IMPORTER SOURCEU ITENTVAL ITOTQTY IPOSRESULTS INEGRESULTS ITOTRESULTS DMINPCT DMINTEST ASESRATE PERUNIT; LABEL US_IMPORTER = 'IMPORTER**========' SOURCEU = 'CUSTOMS VALUE*DATA SOURCE**=============' ITENTVAL = 'CUSTOMS VALUE*(A)*=============' ITOTQTY = 'TOTAL QUANTITY*(B)*============' IPOSRESULTS = 'TOTAL OF*POSITIVE*COMPARISON*RESULTS*(C)*==========' INEGRESULTS = 'TOTAL OF*NEGATIVE*COMPARISON*RESULTS*(D)*==========' ITOTRESULTS = 'ANTIDUMPING*DUTIES DUE*(see footnotes)*(E)*==============' DMINPCT = 'RATE FOR*DE MINIMIS TEST*(percent)*(E/A)x100*==============' DMINTEST = 'IS THE RATE*AT OR BELOW*DE MINIMIS?**===========' ASESRATE = '*AD VALOREM*ASSESSMENT*RATE*(percent)*(E/A)x100*==========' PERUNIT = 'PER-UNIT*ASSESSMENT*RATE*($/unit)*(E/B) *==========' ; FORMAT ITENTVAL ITOTQTY COMMA16.2 DMINPCT ASESRATE PERUNIT COMMA8.2; TITLE3 "IMPORTER-SPECIFIC DE MINIMIS TEST RESULTS AND ASSESSMENT RATES"; TITLE4 &ASSESS_TITLE4; TITLE5 "FOR DISPLAY PURPOSES, THE DE MINIMIS PERCENT IS NOT ROUNDED"; FOOTNOTE1 &ASSESS_FOOTNOTE1; FOOTNOTE2 &ASSESS_FOOTNOTE2; FOOTNOTE4 "*** BUSINESS PROPRIETARY INFORMATION SUBJECT TO APO ***"; FOOTNOTE5 "&BDAY, &BWDATE - &BTIME"; RUN; %MEND PRINT_ASSESS; %IF &ABOVE_DEMINIMIS_STND = YES %THEN %DO; %LET ASSESS_FOOTNOTE1 = "IF C IS GREATER THAN THE ABSOLUTE VALUE OF D, THEN THE ANTIDUMPING DUTIES DUE "; %LET ASSESS_FOOTNOTE2 = "ARE THE SUM OF C AND D, OTHERWISE THE ANTIDUMPING DUTIES DUE ARE ZERO."; %LET ASSESS_TITLE4 = "STANDARD METHOD, OFFSETTING POSITIVE COMPARISON RESULTS WITH NEGATIVES"; %PRINT_ASSESS(IMPSTND) %END; %IF &ABOVE_DEMINIMIS_MIXED = YES %THEN %DO; %LET ASSESS_FOOTNOTE1 = "FOR SALES THAT FAIL THE COHEN'S-D TEST, AD DUTIES DUE ARE THE SUM OF C AND D (IF C>|D|) OR ZERO."; %LET ASSESS_FOOTNOTE2 = "FOR SALES THAT PASS COHEN'S-D TEST, AD DUTIES DUE ARE THE SUM OF C."; %LET ASSESS_TITLE4 = "MIXED ALTERNATIVE METHOD: FOR SALES FAILING COHEN'S-D ONLY, OFFSET POSITIVE COMPARISON RESULTS WITH NEGATIVES"; %PRINT_ASSESS(MIXED) %END; %IF &ABOVE_DEMINIMIS_ALT = YES %THEN %DO; %LET ASSESS_FOOTNOTE1 = "THE ANTIDUMPING DUTIES DUE ARE THE SUM OF THE POSITIVE RESULTS (C)"; %LET ASSESS_FOOTNOTE2 = ; %LET ASSESS_TITLE4 = "A-to-T ALTERNATIVE METHOD: TOTAL DUMPING IS EQUAL TO TOTAL POSITIVE COMPARISON RESULTS"; %PRINT_ASSESS(IMPTRAN) %END; %END; %MEND US18_ASSESSMENT; /******************************************/ /* US-19: REPRINT FINAL CASH DEPOSIT RATE */ /******************************************/ %MACRO US19_FINAL_CASH_DEPOSIT; %IF %UPCASE(&PER_UNIT_RATE) = NO %THEN %DO; %LET PREFIX = WTAVGPCT; %LET LABEL_STND = "AD VALOREM*WEIGHTED AVERAGE*MARGIN RATE*(PERCENT)*STANDARD METHOD*================"; %LET LABEL_MIXED = "AD VALOREM*WEIGHTED AVERAGE*MARGIN RATE*(PERCENT)*MIXED ALTERNATIVE*METHOD*================="; %LET LABEL_ALT = "AD VALOREM*WEIGHTED AVERAGE*MARGIN RATE*(PERCENT)*A-to-T ALTERNATIVE*METHOD*=================="; %LET CDFORMAT = PCT_MARGIN.; %END; %ELSE %IF %UPCASE(&PER_UNIT_RATE) = YES %THEN %DO; %LET PREFIX = PER_UNIT_RATE; %LET LABEL_STND = "PER-UNIT*WEIGHTED AVERAGE*MARGIN RATE*STANDARD METHOD*==============="; %LET LABEL_MIXED = "PER-UNIT*WEIGHTED AVERAGE*MARGIN RATE*MIXED ALTERNATIVE*METHOD*================="; %LET LABEL_ALT = "PER-UNIT*WEIGHTED AVERAGE*RATE*A-to-T ALTERNATIVE*METHOD*=================="; %LET CDFORMAT = UNIT_MARGIN.; %END; PROC PRINT DATA = ANSWER NOOBS SPLIT = '*'; TITLE3 "SUMMARY OF CASH DEPOSIT RATES"; TITLE5 "PERCENT OF SALES PASSING THE COHEN'S D TEST: %CMPRES(&PERCENT_VALUE_PASSING)"; TITLE6 "IS THERE A MEANINGFUL DIFFERENCE BETWEEN THE STANDARD METHOD AND THE MIXED-ALTERNATIVE METHOD: %CMPRES(&MA_METHOD)"; TITLE7 "IS THERE A MEANINGFUL DIFFERENCE BETWEEN THE STANDARD METHOD AND THE A-to-T ALTERNATIVE METHOD: %CMPRES(&AT_METHOD)"; TITLE8 " "; VAR &PREFIX._STND &PREFIX._MIXED &PREFIX._ALT; LABEL &PREFIX._STND = &LABEL_STND &PREFIX._MIXED = &LABEL_MIXED &PREFIX._ALT = &LABEL_ALT; FORMAT &PREFIX._STND &PREFIX._MIXED &PREFIX._ALT &CDFORMAT; FOOTNOTE1 "*** BUSINESS PROPRIETARY INFORMATION SUBJECT TO APO ***"; FOOTNOTE2 "&BDAY, &BWDATE - &BTIME"; RUN; %MEND US19_FINAL_CASH_DEPOSIT;